Commit graph

455 commits

Author SHA1 Message Date
Anas Nashif
e11a71dea0 tests: posix: remove unrelated tags
Remove unrelated tags: net, socket.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-30 11:23:11 -05:00
Christopher Friedt
fe456ee5be tests: posix: test pthread_cleanup_push() / pop()
Add a test for pthread_cleanup_push() and
pthread_cleanup_pop().

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-11-29 10:08:44 +01:00
Peter Mitsis
a51bd53cef tests: Update posix common test for Xtensa
Updates the posix common test so that it will pass on Xtensa SMP
boards such as intel_adsp_ace15_mtpm. This involves ensuring that
a newly created thread does not attempt access/modify the stack of
a thread that is currently running on a different CPU.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-11-27 20:10:51 -05:00
Christopher Friedt
caf72569a9 tests: posix: common: test pthread_getconcurrency()
Add functional tests for pthread_getconcurrency() and
pthread_setconcurrency().

Note: the specification explicitly says

> an implementation can always ignore any calls to
> pthread_setconcurrency() and return a constant for
> pthread_getconcurrency()

The implementation and tests could be up for revision at a future
time when optimizations are considered and there is a better
system in placeo for documenting POSIX options and deviations.

Any such optimizations should be explicitly controlled via
Kconfig.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-11-27 08:26:31 -05:00
Christopher Friedt
c0f2038c26 tests: posix: headers: check for pthread_getconcurrency()
Check for the existence of pthread_getconcurrency() and
pthread_setconcurrency().

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-11-27 08:26:31 -05:00
Christopher Friedt
5f64a47d52 tests: posix: headers: support pthread_setcancelstate() / type()
The function pthread_setcancelstate() has been supported for
some time already in Zephyr. For some reason, it was not being
checked in the "headers" testsuite.

Additionally, check for pthread_setcanceltype() since it was
added in a prior commit.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-11-26 05:55:08 -05:00
Christopher Friedt
d2e729233d tests: posix: headers: add verification tests for more constants
Ensure that the "headers" test checks that the following constants
are defined:

* PTHREAD_PROCESS_SHARED
* PTHREAD_PROCESS_PRIVATE
* PTHREAD_COND_INITIALIZER
* PTHREAD_MUTEX_INITIALIZER
* PTHREAD_CANCELED

They were already defined by previous commits, but the test had not
been updated.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-11-25 06:29:16 -05:00
Christopher Friedt
505e9be2e1 tests: posix: headers: ensure pthread_condattr_getclock() exist
These calls were added some time ago, so ensure they are checked
for existence.

* pthread_condattr_getclock()
* pthread_condattr_setclock()

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-11-25 06:29:16 -05:00
Christopher Friedt
131220cb95 tests: posix: headers: check pthread_spin_lock() et al exist
The simple header test was not updated to verify that the
following functions were implemented even though they were
implemented some time ago.

* pthread_spin_destroy()
* pthread_spin_init()
* pthread_spin_lock()
* pthread_spin_trylock()
* pthread_spin_unlock()

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-11-25 06:29:16 -05:00
Christopher Friedt
0e11bcf5a0 tests: posix: add tests to ensure pthread_key_delete() works
Ensure that the correct key is deleted via pthread_key_delete().

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-11-24 10:47:28 -05:00
Christopher Friedt
41b7c17ac4 tests: posix: pthread: check that pthread_atfork() exists
Add a simple existence check that pthread_atfork() has
some kind of implementation. The function is mandatory
by all conforming POSIX systems.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-11-23 00:59:32 -05:00
Alberto Escolar Piedras
587c43a602 tests/posix/common: Fix filtering for POSIX arch
All these tests where filtered for the whole POSIX
architecture, but quite a few of them can be run in
native_sim.
So let's filter out native_posix(_64) in general,
(allowing other native simulator based targes),
and filter for thsi arch out explicitly the 2 tests
which need NEWLIB as this arch does not provide it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-25 07:44:12 -04:00
Alberto Escolar Piedras
32ea1566db tests/posix/fs: Improve filtering around posix arch
These tests cannot be run on the native_posix(_64) targets,
so let's filter them explicitly. Before they were filtered
due to the "filter", but using platform_exclude is faster.

Also the tests that depend on newlib cannot be run
in this architecture at all, so let's filter them by
architecture too.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-25 07:44:12 -04:00
Alberto Escolar Piedras
a2d1e979ef tests posix timer: Fix timer check
The timer check does not work properly for platforms
which have a system tick timer with a period that
does not properly divide the configured time interval.

In those, depending on when the timer is started and
stopped, one signal less may be received.

This is for example the case for nrf5x platforms,
where the system tick timer is driven by a 32.768KHz
clock.

=> Correct the test, to accept receiving 1 signal
too little during the wait.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-25 07:44:12 -04:00
Anas Nashif
345735d0a8 tests: remove CONFIG_ZTEST_NEW_API in all tests
Remove all usage of CONFIG_ZTEST_NEW_API from tests and sample as this
is now enabled by default.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-20 15:04:29 +02:00
Alberto Escolar Piedras
826c54efc9 tests posix pthread_pressure: Fix for native targtets
The infinite loop during the test needs to be broken
with a small delay when built for native targets.
Let's add it.
Note that this delay is only added for ARCH_POSIX targets
and not any other.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-20 15:01:25 +02:00
Alberto Escolar Piedras
11aa5c513f tests posix getopt: Minor fix for native targets
This test should be compiled without host headers
when built without the host libC, and at the same
time, it does not support building with the host
libC, so let's remove the condition that includes
the host libC header to avoid extra confusion.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-20 15:01:25 +02:00
Alberto Escolar Piedras
50793e32a8 tests posix event_fd: Fix for native targets
The infinite loop during the stress needs to be broken
with a small delay when built for native targets.
Let's add it.
Note that this delay is only added for ARCH_POSIX targets
and not any other.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-20 15:01:25 +02:00
Arunmani Alagarsamy
71c1f89440 tests: posix: common: timer: add test for SIGEV_THREAD
this flag enables the timer expiry handler runs on thread

Signed-off-by: Arunmani Alagarsamy <arunmani@linumiz.com>
2023-10-20 14:52:07 +02:00
Evgeniy Paltsev
433a85e7bf test: posix: skip nanosleep testcase for ARC HSDK boards
The comparison of cycles we get with k_cycle_get_32 may be
incorrect if counter wrap happened. In case of ARC HSDK and
ARC HSDK4xD platforms we have high counter clock frequency
(500MHz or 1GHz) so counter wrap quite likely to happen if
we wait long enough. As in some test cases we wait more than
1 second, there are significant chances to get false-positive
assertion.

So let's skip nanosleep testcase for ARC HSDK and ARC HSDK4xD
boards.

The proper fix is to use k_cycle_get_64 in this test case,
but we need to provide k_cycle_get_64 support for ARC HSDK and
ARC HSDK4xD platforms first.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-10-13 21:59:40 -04:00
Christopher Friedt
254c6711ed tests: posix: common: init check for stdin, stdout, and stderr
Add a test to help ensure stdin, stdout, and stderr are
initialized statically.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-10-13 04:48:47 -04:00
Hake Huang
cdd17ce100 test: posix: nanosleep: use k_cycle_64 as possible
as posix nanosleep is actually call us, so we need use a
higher clock to compare the result. try to use k_cycle_64
as possible.

Co-authored-by: Christopher Friedt <cfriedt@meta.com>
Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2023-10-13 10:05:06 +03:00
Hake Huang
0136759707 test: posix: common: nanosleep test fix
in test_nanosleep_execution, the

actual_ns = k_cyc_to_ns_ceil64((now - then * selection));

is wrong, according to posix driver code

lib/posix/clock.c

line: 156
	if ((flags & TIMER_ABSTIME) == 0) {
		ns += uptime_ns;
	}

so we need change to

actual_ns = k_cyc_to_ns_ceil64((now + then * selection));

fixing: #62889

Co-authored-by: Christopher Friedt <cfriedt@meta.com>
Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2023-10-13 10:05:06 +03:00
Martin Åberg
7a9600816a tests: posix: Enable pthread_pressure test on SPARC
This sets the stack size appropriate for SPARC. Tested on the board
configurations qemu_leon3 and gr716a_mini.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2023-10-08 11:24:19 +01:00
Flavio Ceolin
15aa3acaf6 kconfig: Remove MP_NUM_CPUS usage
Zephyr's code base uses MP_MAX_NUM_CPUS to
know how many cores exists in the target. It is
also expected that both symbols MP_MAX_NUM_CPUS
and MP_NUM_CPUS have the same value, so lets
just use MP_MAX_NUM_CPUS and simplify it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-03 17:45:53 +01:00
Jaxson Han
eeaf3bdb2d tests: posix: eventfd: Move thread from stack to data section
The test case allocate struct k_thread thread in the stack. This will
lead the random initial value of thread and thus cause the test cases
randomly hang. To fix such issue, move the declartion of struct k_thread
thread outside the function as a stacic variable.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2023-09-22 09:25:12 +02:00
Johann Fischer
f67dd39bb2 drivers: ramdisk: use devicetree to instantiate RAM disk
Rework RAM disk driver to be configured using devicetree and
support multiple instances.

This patch also removes a copy of the RAM disk driver,
tests/subsys/fs/fat_fs_dual_drive/src/disk_access_test_drv.c,
that was there for testing multiple disk drivers support.

Bonus: one SYS_INIT() less and a memory region can be exported to the
host.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-09-18 17:36:50 +02:00
Tom Finet
ceb59951c5 posix: clock_nanosleep tests
Adds error and lower bounds tests for the posix clock_nanosleep
function. Refactors common test functions to be shared by both
clock_nanosleep and nanosleep tests.

Signed-off-by: Tom Finet <tom.codeninja@gmail.com>
2023-08-30 13:02:58 -07:00
Mateusz Marszalek
295eb1b1a0 POSIX: Add tests for pthread_condattr
Add test coverage for init, destroy, setclock, getclock

Signed-off-by: Mateusz Marszalek <matti.marszalek@gmail.com>
2023-08-30 13:01:03 -07:00
Anas Nashif
71eee6da4b tests: fs: add more tags
Add module names as tags, to trigger CI on those tests when module has
changed.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-08-24 13:41:26 -04:00
Jaxson Han
f840b85b15 tests: posix: pthread_pressure: Correct the 64BIT naming
Correct the Kconfig with 64BIT condition instead of 64_BIT.
Slightly refine the if condition as they are mutually exclusive.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2023-08-21 13:27:07 +02:00
Grant Ramsay
973393ae18 Revert "test: Exclude qemu_cortex_a53_smp from portability.posix.eventfd"
This reverts commit d24880e358.

The issue was fixed by a2d29025038dece141ab71545c83166384821369.

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
2023-08-17 11:54:08 -04:00
Johan Hedberg
03905f7e55 boards: x86: Add intel_ prefix to Elkhart Lake boards
This follows the same convention that has already been adopted by Intel
Alder Lake and Raptor Lake boards.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2023-08-15 11:24:35 +00:00
Daniel Leung
efeb2d13a7 tests: net: renames shadow variables
Renames	shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:43 +00:00
Daniel Leung
9a1b95f372 tests: posix: rename shadow variables
Rename shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:12 +00:00
Yong Cong Sin
43123e77c0 posix: signal: extend strsignal buf to cover entire INT range
extends the char buffer in the strsignal function to cover the
entire range of `int`

Had to use `-INT_MAX` as the compiler resolves

```
STRINGIFY(INT_MIN)
```

to:

```
(-2147483647 - 1)
```

instead of:

```
-2147483648
```

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-08-04 15:54:18 -04:00
Christopher Friedt
daac5177c1 tests: posix: mutex: test pthread_mutex_timedlock() ETIMEDOUT
Add a test to ensure that `pthread_mutex_timedlock()` returns
`ETIMEDOUT` when it fails.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-02 12:04:34 -04:00
Jaxson Han
cf71de42dd tests: posix: Fix the testcases by increasing the stack size
Fix the testcases failures by increasing the stack size.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2023-08-02 16:34:04 +02:00
Peter Mitsis
38352ae13c test: Relocate posix mqueue receive buffer
For platforms that select Kconfig option CONFIG_KERNEL_COHERENCE,
the receive buffer used in mq_timedreceive() must not be on the
stack. This is because the k_msgq that underlies the POSIX mqueue
will attempt to perform a direct to buffer copy from the sender
when there is a waiting reader.

Fixes #60796

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-07-31 10:08:34 +02:00
Christopher Friedt
e7c23b392f tests: posix: common: check return value in pthread_join()
Ensure that the thread return value is set by `pthread_join()`
when `status` is non-NULL.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-07-30 19:17:49 -04:00
Christopher Friedt
033d772d07 tests: posix: common: pthread_join should fail on detached
A thread that has been previously detached using
`pthread_detach()` should not be able to be joined. A recent
change made it so that `pthread_join()` would always report
success (0), even when `ret` (return value) had an error.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-07-30 12:51:12 -04:00
Christopher Friedt
5a28297cf3 pthread: test: facilitate dynamically allocated thread stacks
Tests for dynamically allocated POSIX thread stacks.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2023-07-24 12:59:43 -04:00
Carlo Caione
d24880e358 test: Exclude qemu_cortex_a53_smp from portability.posix.eventfd
The test is failing for (so far) unknown reasons, blocking several PRs.
Exclude it until a proper investigation finds the root cause.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-07-21 06:23:00 -04:00
Jai Arora
81ef6b5afb posix: Adds test case for pthread_equal functions
Adds test case for pthread_equal
Adds test coverage for same and different thread id

Signed-off-by: Jai Arora <infolinesoni@gmail.com>
2023-07-20 16:24:16 +02:00
Christopher Friedt
b5f8c7154d tests: posix: barrier: use consistent test names
Test names were changed recently to change
"test_posix_pthread_..." to "test_..." for brevity.

Make the same change to "test_posix_pthread_barrier".

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-07-19 09:11:29 -04:00
Yong Cong Sin
5970543999 test: posix: signal: add test for big nsig number
Add an extra test config to test large number of signals.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-07-18 15:35:42 -04:00
Yong Cong Sin
335acf817d posix: signal: implement strsignal
Implementation and ztest for strsignal.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-07-18 15:35:42 -04:00
Yong Cong Sin
ff4b81e5e5 posix: signal: implement sigismember
Implementation and ztest for sigismember.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-07-18 15:35:42 -04:00
Yong Cong Sin
88cd494430 posix: signal: implement sigdelset
Implementation and ztest for sigdelset.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-07-18 15:35:42 -04:00
Yong Cong Sin
8011449542 posix: signal: implement sigaddset
Implementation and ztest for sigaddset.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-07-18 15:35:42 -04:00