Commit graph

245 commits

Author SHA1 Message Date
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
Yong Cong Sin b9720e27c0 posix: signal: implement sigfillset
Implementation and ztest for sigfillset.

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

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-07-18 15:35:42 -04:00
Yong Cong Sin e3c49b9573 posix: signal: add initial header
Initial header for the signal APIs.
APIs to be implemented in later commit.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-07-18 15:35:42 -04:00
Harshil Bhatt 8b2a41904d posix: implement timer_getoverrun()
Address missing POSIX function and tests #59956

Signed-off-by: Harshil Bhatt <harshilbhatt2001@gmail.com>
2023-07-10 09:30:33 +02:00
Yong Cong Sin 0736448d37 tests: posix: uname: add test
add ztest for uname api

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-07-09 16:57:16 -04:00
Harshil Bhatt 886325cc1d posix: add tests for pthread_barrierattr
add test coverage for init, destroy, setpshared and getpshared

Signed-off-by: Harshil Bhatt <harshilbhatt2001@gmail.com>
2023-07-09 10:40:57 -04:00
Christopher Friedt 807d923955 tests: posix: nanosleep: condense test cases
Most Zephyr testsuites do not break tests down to the level of
granularity that `nanosleep()` tests, and this change makes
reports less verbose.

This change makes the `nonosleep()` test cases
significantly less verbose.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-07-06 11:47:07 -04:00
Christopher Friedt 85110ad917 tests: posix: use standard headers and canonical order
The POSIX testsuite should be run with standard POSIX
header locations.

Additionally, reorder headers to follow the recommendation
in #41543.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-07-06 11:47:07 -04:00
Christopher Friedt 7f3c9708cc tests: posix: rename some files for brevity
This makes the POSIX common testsuite consistent with some
other testsuites.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-07-06 11:47:07 -04:00
Christopher Friedt 84afb9faa1 tests: posix: reduce test name verbosity
There were a number of tests that started with `test_posix_..`.

The `test_` prefix is necessary, but the `posix_` part is self-
evident, so it makes sense to shorten that.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-07-06 11:47:07 -04:00