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>
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>
This reverts commit d24880e358.
The issue was fixed by a2d29025038dece141ab71545c83166384821369.
Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
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>
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>
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>
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>
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>
Set up a test fixture to reduce repetition and split
testsuite into blocking and nonblocking tests.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
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>
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>
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>
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>
Some platforms with insufficient ram were incorrectly included
in this test since #47288.
Fixes#47734
Signed-off-by: Christopher Friedt <cfriedt@fb.com>
Add test permutations that run against the newlib
libc against
* tests/posix/eventfd
* tests/posix/eventfd_basic
* tests/posix/getopt
Signed-off-by: Christopher Friedt <cfriedt@fb.com>
* ensure test permutations are prefixed with `portability.posix`
* ensure test permutations include the `posix` tag
* ensure consistent order of `arch_exclude` and `tags`
Signed-off-by: Christopher Friedt <cfriedt@fb.com>
* Convert test suite declaration to `ZTEST_SUITE()`
and test case declaration to `ZTEST()`.
* add `CONFIG_ZTEST_NEW_API=y` to prj.conf
Fixes#46793
Signed-off-by: Christopher Friedt <cfriedt@fb.com>
In order to bring consistency in-tree, migrate all tests to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Convert remaining tests and samples to using find_package() instead of
literally including the CMake boilerplate code.
Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
Move to CMake 3.20.0.
At the Toolchain WG it was decided to move to CMake 3.20.0.
The main reason for increasing CMake version is better toolchain
support.
Better toolchain support is added in the following CMake versions:
- armclang, CMake 3.15
- Intel oneAPI, CMake 3.20
- IAR, CMake 3.15 and 3.20
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit adds the following tests:
* check eventfd with initval != 0
* check write counter overflow
* check if eventfd is blocked after read
* check if writing zero does not unblock
* check if nonblocking eventfd poll() behaviour is identical to blocking
Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
When there were multiple writes to eventfd, then poll() + read() should
start behaving as just initialized. Test that by verifying poll() will
timeout first and later be notified properly when eventfd is written
once again from the other thread.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Test is configured with CONFIG_POSIX_API=y, so there is no reason to
check for it being enabled in C. Additionally when CONFIG_POSIX_API=n a
much "bigger" posix/sys/socket.h was included instead of net/socket.h,
which should be rather opposite.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
This implements a file descriptor used for event notification that
behaves like the eventfd in Linux.
The eventfd supports nonblocking operation by setting the EFD_NONBLOCK
flag and semaphore operation by settings the EFD_SEMAPHORE flag.
The major use case for this is when using poll() and the sockets that
you poll are dynamic. When a new socket needs to be added to the poll,
there must be some way to wake the thread and update the pollfds before
calling poll again. One way to solve it is to have a timeout set in the
poll call and only update the pollfds during a timeout but that is not
a very nice solution. By instead including an eventfd in the pollfds,
it is possible to wake the polling thread by simply writing to the
eventfd.
Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>