Commit Graph

122 Commits

Author SHA1 Message Date
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
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
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
Christopher Friedt d73bdbf5bd tests: posix: common: add pthread spinlock tests
Exercise the following (which rely mainly on existing Zephyr
utilities)
* `pthread_spin_init()`
* `pthread_spin_destroy()`
* `pthread_spin_lock()`
* `pthread_spin_trylock()`
* `pthread_spin_unlock()`

Additionally, ensure that we do not leak spinlock descriptors.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-07-05 21:06:55 -04:00
Alberto Escolar Piedras 4598d2b372 tests POSIX: Do not filter fully by POSIX arch but by type of build
Some POSIX arch targets support now the POSIX API.
Instead of filtering the architecture fully,
let's limit it to the type of build

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-05 07:01:19 -04:00
Christopher Friedt d9bae7ce65 tests: posix: improvements to pthread_pressure test
* allow `qemu_cortex_a53`
* disallow `qemu_leon3
* remove `TEST_DURATION_S` range
* additional report formatting

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-09 12:27:04 -04:00
Christopher Friedt f35fb33b94 posix: pthread: reimplement pthread_barrier using zephyr objects
Previously pthread_barrier_t was implemented in terms of wait
queues and internal scheduler functions.

This introduced some obstacles and inconsistency. In order
to be more consistent, rely only on Zephyr's public API and
reuse as many concepts as possible.

Deprecate `PTHREAD_BARRIER_DEFINE()` since it's non-standard.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-09 12:27:04 -04:00
Christopher Friedt 15ea0412e4 tests: posix: common: add a small delay in pthread_descriptor_leak
The `aborted _current back from dead` error may appear in this
particular test under Qemu (and in particular Qemu SMP) systems.

A small delay between `pthread_create()` and `pthread_join()`
is sufficient to mitigate the issue.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-05 19:48:39 -04:00
Christopher Friedt d95ecab47e Revert "tests: posix: pthread: init pthread_attr_t on each iteration"
This reverts commit 7c17bda3c2.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-05 19:48:39 -04:00
Anas Nashif a543ba1f4d tests: use integration_platforms where applicable
Use integration_platforms where coverage is provided using one or few
targets instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-05-26 17:52:02 -04:00
Gerard Marull-Paretas 93b63df762 samples, tests: convert string-based twister lists to YAML lists
Twister now supports using YAML lists for all fields that were written
as space-separated lists. Used twister_to_list.py script. Some artifacts
on string length are due to how ruamel dumps content.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-10 09:52:37 +02:00
Christopher Friedt 12ed08a2fb tests: posix: pthread: remove unused pthread return value
Rather than pass an variable address to a `void *` in
`pthread_join()` and do nothing with it, just pass `NULL`.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-04-29 16:53:59 -04:00
Christopher Friedt 7c17bda3c2 tests: posix: pthread: init pthread_attr_t on each iteration
The `test_pthread_descriptor_leak` test was causing a kernel
panic on some platforms. Initially, it was not clear why.

The usual cases were examined - race conditions, stack sizes,
etc. Still no luck.

As it turns out, recycling a thread stack (or at least the
`pthread_attr_t`) in-place does not work on some platforms,
and we need to reinitialize the `pthread_attr_t` and set
set the stack property again prior to calling
`pthread_create()`.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-04-29 16:53:59 -04:00
Chris Friedt 27c25e9b42 tests: posix: test support for SCHED_OTHER
Ensure we test `SCHED_OTHER` functionality along with other
scheduling policies and priorities.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-04-29 13:14:40 -07:00
Chris Friedt ad71b78770 tests: posix: ensure that min and max priority are schedulable
Verify that threads are actually schedulable for min and max
scheduler priority for both `SCHED_RR` (preemptive) and
`SCHED_FIFO` (cooperative).

Fixes #56729

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-04-29 13:14:40 -07:00
Gerard Marull-Paretas 0ebe14beb4 sys: util: migrate all files to DIV_ROUND_UP
ceiling_fraction is deprecated, use DIV_ROUND_UP.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-11 12:00:37 +02:00
Kumar Gala 9d8c7b8f1f tests: posix: common: Add testcase for arm-clang
Add a testcase variant to cover building with arm-clang and
CONFIG_ARMCLANG_STD_LIBC set.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-06 19:50:23 -04:00
Anas Nashif 7de0d6efcf tests: posix: prefix tests with test_
Prefix tests with test_ to allow correct evaluation of output.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-05 10:27:28 +02:00
Chris Friedt 9bde7ec919 Revert "tests: posix: clock: ensure overflow is consistent"
This reverts commit 662f37d906.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-04-04 14:32:10 +02:00
Chris Friedt 93e67fb73f tests: posix: add coverage for fnmatch
Previously, the `fnmatch()` function was available in `lib/util`
but it did not have any test coverage.

After moving it to `lib/posix`, add test coverage to the POSIX
testsuite.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-03-03 17:40:14 +09:00
Chris Friedt 1f20503e46 tests: posix: common: avoid direct pthread_attr_t field access
Avoid directly accessing fields in `pthread_attr_t` and only
access / mutate them with POSIX functions.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Chris Friedt 7be31813da posix: sched: use newlib-compatible SCHED_RR FIFO definitions
Zephyr's `SCHED_RR` and `SCHED_FIFO` definitions were slightly
different than Newlib's. Additionally, the test had hard-coded
magic numbers instead of using symbolic values.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Chris Friedt ecb82784b7 posix: newlib compatible PTHREAD_CREATE_DETACHED and JOINABLE
Define `PTHREAD_CREATE_DETACHED` and
`PTHREAD_CREATE_JOINABLE` to be compatible with the Newlib
definitions.

This is a temporary workaround for #51211 until Newlib
headers are pulled in.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Chris Friedt d1e7ccec24 tests: posix: common: remove duplicate call to pthread_attr_init
There was a second call to `pthread_attr_init()` that reallly had
no sense being there. Also, it seems that there was a call to
`pthread_attr_destroy()` out of perhaps paranoia.

The duplicate call and `pthread_attr_destroy()` can be removed.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Chris Friedt 8e4137f149 tests: posix: clock: ensure overflow is consistent
Add a test to verify previous fixes when calculating time in
seconds for `clock_gettime()`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-04 21:12:58 +01:00
Fabio Baltieri 7db1d17ee3 yamllint: fix all yamllint line-length errors
Fix all line-length errors detected by yamllint:

yamllint -f parsable -c .yamllint $( find -regex '.*\.y[a]*ml' ) | \
  grep '(line-length)'

Using a limit is set to 100 columns, not touching the commandlines in
GitHub workflows (at least for now).

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 01:16:45 +09:00
Chris Friedt 027b79ecc4 tests: posix: add tests for sleep() and usleep()
Previously, there was no test coverage for `sleep()` and
`usleep()`.

This change adds full test coverage.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-11-24 19:31:33 -05:00
Chris Friedt 23a1f0a672 tests: posix: clock: do not use usleep in a broken way
Using `usleep()` for >= 10000000 microseconds results
in an error, so this test was kind of defective, having
explicitly called `usleep()` for seconds.

Also, check the return values of `clock_gettime()`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-11-24 19:31:33 -05:00
Chris Friedt 909185f79c tests: posix: cond: test to ensure there is no resource leakage
Add a test to ensure that `pthread_cond_t` can be used over
and over again and that there is no resource leakage with proper
usage.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-11-19 14:16:38 +09:00
Chris Friedt 47d09c04af tests: posix: mutex: test to ensure there is no resource leakage
Add a test to ensure that `pthread_mutex_t` can be used over
and over again and that there is no resource leakage with proper
usage.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-11-15 05:56:31 +09:00
Chris Friedt ce054404a2 posix: use uint32_t instead of void* for pthread_t
Several other widely-used pthread implementations
abstract `pthread_t` as `uint32_t`. The benefit
there is that we avoid passing around a pointer to
an internal structure (implementation detail).

Additionally, this removes the alias from `k_tid_t`
to `pthread_t` inside of `struct pthread_mutex`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-11-02 15:39:44 +09:00
Michał Barnaś dae8efa692 ztest: remove the obsolete NULL appended to zassert macros
This commit removes the usage of NULL parameter as message in
zassert_* macros after making it optional

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-09-09 07:05:38 -04:00
Gerard Marull-Paretas 79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00
Manuel Arguelles 7f26c1c25c tests: samples: revert timeout change for FVP BaseR
Partially revert commit 0028e97332.
Timeout for tests/posix/common must be still increased for slow
platforms (previously was 120 sec).

Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
2022-08-16 15:51:38 +02:00
Stephanos Ioannidis c19fbce9d1 tests: posix: common: Disable for qemu_leon3
This commit disables the `tests/posix/common` test for the `qemu_leon3`
platform because of the alignment-related failure reported in the
GitHub issue zephyrproject-rtos/zephyr#48992.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-12 10:35:19 +01:00
Fabio Baltieri def230187b test: fix more legacy #include paths
Add a bunch of missing "zephyr/" prefixes to #include statements in
various test and test framework files.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-02 16:41:41 +01:00