Commit graph

422 commits

Author SHA1 Message Date
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
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
Vincent van Beveren
bd0d98bb9e tests: posix: fs: Add tests for stat command
This commit adds tests for the stat command. Stat on the
root of the filesystem is not yet supported.

Signed-off-by: Vincent van Beveren <v.van.beveren@nikhef.nl>
2023-06-23 17:04:34 -04:00
Marcin Niestroj
2bc980f831 tests: eventfd: test wake-up from pending poll()
Make sure that `poll(..., POLLIN)` executed from another thread returns
when `eventfd_write()` is called. Test also the same with `poll(...,
POLLOUT)` and `eventfd_read()` on eventfd with counter equal to
`UINT64_MAX - 1`.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-06-22 16:09:42 -04:00
Christopher Friedt
bfa0a87277 tests: posix: pthread_pressure: enable pthread barrier in twister
In some cases, when GitHub CI is running several Qemu processes,
each with heavy loads, SMP tests have shown some flakiness. This
exhibits itself as something like

```
... pthread_pressure on qemu_riscv32 failed (Timeout)
```

That is actually not at all limited to POSIX or any particular
architecture, but is mainly to do with the host scheduler and
perhaps memory barrier operations being lost in ISA translation
by Qemu.

Collectively, we can refer to these issues as "scheduler noise".

To reduce scheduler noise in the `pthread_pressure` testsuite,
enable `CONFIG_PTHREAD_CREATE_BARRIER` in `testcase.yaml`.

Note: end-users will likely not experience the need to enable
this in `prj.conf`. E.g. the following basic test demonstrates
0 failures locallly.

```
TEST=tests/posix/pthread_pressure
twister --build-only -T $TEST &>/dev/null
FAIL=0
for ((i=0; i < 100; i++)); do
  echo "Run $((i+1))/100"
  twister --test-only -T $TEST &>/dev/null
  if [ $? -ne 0 ]; then
    FAIL=$((FAIL+1))
    echo "Failed $FAIL times"
  fi
done
echo "Failure Rate: $((FAIL))/100"
```

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-12 14:06:10 -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
2d4874dd65 tests: posix: stress test for pthread_create and pthread_join
Recently, a race condition was discovered in `pthread_create()`
and `pthread_join()` that would trigger an assertion in
`kernel/sched.c` of the form below.
```
aborted _current back from dead
```

This was mainly observed in Qemu. Unfortunately, Qemu SMP
platforms exhibit a real and measurable "scheduler noise"
which makes testing rather difficult.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-05 19:48:39 -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
Declan Snyder
4c8b18920a tests: posix headers: RT1015 increase RAM
RT1015 needs more RAM to do this test, increase size of Zephyr SRAM
by switching zephyr,sram to the OCRAM allocation of the FLEXRAM.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-06-05 10:35:38 +02:00
Christopher Friedt
386f6c7006 tests: posix: eventfd: add stress test
This test simply counts how many times `eventfd_read()`
and `eventfd_write()` can be called on an
`eventfd(0, EFD_SEMAPHORE | EFD_NONBLOCK)` file
descriptor.

Prior to the recent changes in `eventfd`, we were seeing
approximately < 1000 writes / s. However, the previous
`eventfd` implementation would fail this test with the
result that the number of successful reads was far greater
than the number of successful writes.

This should be impossible, and with the recent `eventfd`
changes that was fixed. Additionally, we are seeing an
increase in over 40x for non-blocking eventfd reads and
writes.

```
START - test_stress
I: BOARD: qemu_riscv64_smp
I: TEST_DURATION_S: 5
I: UPDATE_INTERVAL_S: 1
I: avg: 48537 reads/s
I: avg: 48575 writes/s
PASS - test_stress in 5.002 seconds
```

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-02 18:45:46 -04:00
Christopher Friedt
d370361fe5 tests: eventfd: blocking read-write test for deadlock bug
Previously, the prototypical use case for `eventfd()` was not
possible in Zephyr due to a deadlock associated with the
`fdtable.c` `k_mutex`.

The prototypical use case for `eventfd()` is to make a
blocking call to `eventfd_read()` from one thread, and then
from another thread, call `eventfd_write()` to "wake up" the
reading thread.

This additional test case ensures that Zephyr supports the
prototypical `eventfd()` use case.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-02 18:45:46 -04:00
Christopher Friedt
cf7c404aeb tests: posix: eventfd: use reopen in test_write_then_read
Use `reopen()` in one additional place in the eventfd
testsuite.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-02 18:45:46 -04:00
Christopher Friedt
5a7b343d9d tests: posix: eventfd: split into blocking and nonblocking
Set up a test fixture to reduce repetition and split
testsuite into blocking and nonblocking tests.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-05-30 10:46:06 -04:00
Christopher Friedt
d3a602ef85 tests: posix: eventfd: normalize includes
Include standard headers first, and then ensure that the
convention of `<zephyr/posix/...>` is followed for internal
POSIX sources.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-05-30 10:46:06 -04:00
Christopher Friedt
26b523bf06 tests: posix: eventfd: reduce testing requirements and scope
In order to reduce churn in CI, test only with the default libc.

Additionally, reduce Kconfig options in `prj.conf` to minimum.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-05-30 10:46:06 -04:00
Christopher Friedt
49d0dface4 tests: posix: eventfd: be less repetitive in naming
Instead of `ZTEST(eventfd, test_eventfd_...)` use
`ZTEST(eventfd, test_...)`.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-05-30 10:46:06 -04:00
Christopher Friedt
6da81c8ebf tests: posix: eventfd: consistent testsuite name
Make the cmake project and suite name consistent.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-05-30 10:46:06 -04:00
Christopher Friedt
cc9bc2a5e0 tests: posix: eventfd: consilidate into one testsuite
Merge the `eventfd_basic` testsuite with the `eventfd`
testsuite in order to reduce churn in CI.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-05-30 10:46:06 -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
Jakub Rzeszutko
25a3977709 getopt: extend ztests scope
Adding a test to detect problems in the cooperation of the getopt
and logger modules. It would detect issue: #57520

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2023-05-09 11:03:44 -04:00