Commit graph

33 commits

Author SHA1 Message Date
Christopher Friedt e223d01b67 tests: posix: shorten the filter in testcase.yaml
CONFIG_NATIVE_LIBC can be used in place of
CONFIG_NATIVE_BUILD and CONFIG_EXTERNAL_LIBC

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2024-01-17 04:59:16 -05: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 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
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
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
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
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
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
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 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
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
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
Christopher Friedt fe8dcdf4a3 tests: posix: eventfd: make min_ram a common test parameter
Some platforms with insufficient ram were incorrectly included
in this test since #47288.

Fixes #47734

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
2022-07-13 11:56:42 -04:00
Christopher Friedt 0583ef71f5 tests: posix: additional tests against newlib
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>
2022-07-05 12:53:49 -04:00
Christopher Friedt 2bf3b45cbb tests: posix: consistent naming and tagging for posix tests
* 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>
2022-07-05 12:53:49 -04:00
Christopher Friedt d0f497c821 tests: posix: use new ztest api
* 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>
2022-06-28 11:07:12 +02:00
Gerard Marull-Paretas ade7ccb918 tests: migrate includes to <zephyr/...>
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>
2022-05-06 20:02:14 +02:00
Henrik Brix Andersen 265cdf8dc6 cmake: use find_package() instead of literal include in tests and samples
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>
2021-11-01 10:33:09 -04:00
Torsten Rasmussen 1cccc8a8fe cmake: increase minimal required version to 3.20.0
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>
2021-08-20 09:47:34 +02:00
Rafał Kuźnia d897bd1e74 tests: posix: eventfd: increase test coverage with polling
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>
2020-10-02 11:34:19 +02:00
Marcin Niestroj add51d809c tests: posix: eventfd: test read and poll after multiple writes
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>
2020-07-20 16:21:37 +02:00
Anas Nashif 1200222ff8 test: posix: fix identifier
Follow convention for identifying tests.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-06-25 22:36:17 -05:00
Marcin Niestroj 398f22b34a tests: eventfd: drop POSIX_API ifdeffery
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>
2020-06-25 12:14:40 +02:00
Paul Sokolovsky 32270ae1b9 tests: posix: eventfd: Don't mix POSIX and Zephyr kernel APIs
K_MSEC() shouldn't be used with poll(), as they come from 2 different
API domains.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2020-05-08 17:31:45 +02:00
Tobias Svehagen ca872a44c1 lib: posix: Add support for eventfd
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>
2020-04-28 09:57:41 +03:00