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>
Compilation of this test on nucleo_f103rb fails because "region 'RAM'
overflowed by 136 bytes". Since this board has a ram size of 20k, we set
the limit for this test at the next usual size 32k.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Add a trivial suite that simply ensures headers exist and that
they supply standard symbols and constants.
These tests are intended to be ordered exactly as the respective
feature appears in the respective specification at
https://pubs.opengroup.org/onlinepubs/9699919799
Over time, as POSIX support improves, we can enable additional
checks.
If `CONFIG_POSIX_API=n`, then we simply ensure that the header
can be included, that constants and structures exist, including
the existence of required fields in each structure.
We check that a constant exist, by comparing its value against
an arbitrary number. If the constant does not exist, it would
of course be a compile error.
```
zassert_not_equal(-1, POLLIN);
```
We check that a structure contains required fields by
comparing the field offset with an arbitrary number. If
the field does not exist, of course, there would be a
compile error.
```
zassert_not_equal(-1, offsetof(struct pollfd, fd));
```
For non-scalar constants, we simply attempt to assign
a value to the specific type:
```
struct in6_addr any6 = IN6ADDR_ANY_INIT;
```
If `CONFIG_POSIX_API=y`, then we additionally check that required
functions are non-NULL (limited to what is currently supported in
Zephyr).
```
zassert_not_null(pthread_create);
```
Note: functional verification tests should be done outside of this
test suite.
Signed-off-by: Chris Friedt <cfriedt@meta.com>
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>
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>
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>
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>
Declarations for `getopt()` should be in `<unistd.h>`
according to the spec. The extended versions `getopt_long()`
and `getopt_long_only()` are declared in `<getopt.h>`.
Signed-off-by: Chris Friedt <cfriedt@meta.com>
Previously, there was no test coverage for `sleep()` and
`usleep()`.
This change adds full test coverage.
Signed-off-by: Chris Friedt <cfriedt@meta.com>
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>
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>
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>
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>
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>
Partially revert commit 0028e9733295316d152eba07bf56677d83f4b1b5.
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>
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>
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 a simple test to ensure that we can create and join a
single thread `CONFIG_MAX_PTHREAD_COUNT` * 2 times. If
there are leaks, then `pthread_create()` should
eventually return `EAGAIN`. If there are no leaks, then
the test should pass.
Fixes#47609
Signed-off-by: Christopher Friedt <cfriedt@fb.com>
Timeout must be increased for fvp_baser_aemv8r_aarch32 board. Enabling
MPU on this board makes simulation slower.
Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
This change adds coverage for picolibc in
* tests/posix/eventfd
* tests/posix/eventfd_basic
* tests/posix/getopt
Fixes#47288
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>
Since `CONFIG_GETOPT=y` is specified in `prj.conf`,
it does not make sense to filter for `CONFIG_GETOPT`.
Additionally, we should run a permutation explicitly
with newlib, for consistency.
Signed-off-by: Christopher Friedt <cfriedt@fb.com>
As Zephyr currently requires CMake version 3.20.0, update all
occurrences of cmake_minimum_required.
Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
Now that picolibc's malloc arena configuration always allocates
some space, we don't need explicit allocations for tests.
Signed-off-by: Keith Packard <keithp@keithp.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>
As described in
https://pubs.opengroup.org/onlinepubs/7908799/xsh/pthread_once.html.
The behavior of pthread_once() is undefined if once_control has
automatic storage duration or is not initialized by PTHREAD_ONCE_INIT
However, in Zephyr, the implementation is incorrect. If the init value
is PTHREAD_ONCE_INIT, the program will never run the init_func.
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
exclude newlib for posix testing as the MAX_HEAP_SIZE will be
too small if enabled NEWLIBC
fixing: #43873
Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
Various obsolote and misnamed platfomrs in test filters theat went
undetected for a while.
Fixes#41222
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Increase main stack size (in 128 bytes) to make these tests run
successfully on qemu_x86 platform.
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>
The test assumed initial equality between CLOCK_MONOTONIC and
CLOCK_REALTIME and also assumed coarse granularity for each clock.
Neither of those assumptions are solid.
Furthermore, the test failed on multiple vendor boards which caused
some concern.
Remove the poorly conditioned tests and remove some comments
/ printks.
Fixes#35703
Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
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>
The ehl_crb board has hardware issue that prevents this test from
being able to pass this otherwise-correct test. So exclude ehl_crb
from the testcase.yaml.
Fixes#33544.
Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
This k_usleep(1) is a tick alignment, not a workaround. Simple
reword to avoid confusion.
Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>