Commit graph

212 commits

Author SHA1 Message Date
Alberto Escolar Piedras 008efecf5d Revert "tests/kernel: Bump kobj thread bitmask size for a few tests"
This reverts commit 9b43fed10a.

This PR introduced 2 regressions in main CI:
71977 & 71978
Let's revert it by now to get main's CI passing again.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-04-26 10:10:24 +00:00
Andy Ross 9b43fed10a tests/kernel: Bump kobj thread bitmask size for a few tests
A scheduler fix for free memory usage on aborted threads is now using
a per-CPU dummy thread instead of a single stack-based one at startup.
These static thread objects need spots in the kobj bitmasks, and a few
tests are sitting right at the default limit (16 threads).

Signed-off-by: Andy Ross <andyross@google.com>
2024-04-25 15:12:02 +02:00
Reto Schneider f45b48fc51 sys: byteorder: Add 40 bit variants
This adds sys_*_*40 functions that operation on a 40 bits values.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2024-03-26 19:32:27 -04:00
Reto Schneider f4430827d8 tests: kernel: common: lto: Exclude builds with warning
Trying to enable LTO when CODE_DATA_RELOCATION is already enabled
produces a warning.

This commit prevents twister from building such combinations for
kernel.common.lto.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2024-03-22 17:42:35 -04:00
Radoslaw Koppel 53becb05bf tests: kernel: common: Enable tests with LTO
This commit enables some kernel tests with
Link Time Optimization enabled.

Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
2024-02-02 19:49:36 +01:00
Anas Nashif 2b43582236 tests: add a tag for nano libc tests
tag nano libc tests with nano so we can exclude them if needed. Now they
cause issues when collecting coverage information from tests.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-12-21 09:18:44 +01:00
Alberto Escolar Piedras 7a778ebc2d tests/kernel/*: Switch integration platform to native_sim
Swith integration_platforms from native_posix(_64)
to native_sim(_64).
And replace it also in a comment.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-30 09:42:25 -05:00
Alberto Escolar Piedras fbf1c19bd6 tests/kernel/common: Enable errno test on native_sim
Enable this test also on native_sim when not using the host
C library

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-30 09:42:25 -05:00
Keith Packard d04c834c0f tests/kernel: Fix test printk output for new printf variants
In minimal mode, format modifiers are not supported, leading to a lack
of width and precision support.

long long values are presented correctly in either long long or floating
mode.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-11-20 06:07:58 -05:00
Alexander Razinkov 5725585112 tests: kernel: common: added test on atomic_t overflow
Added test to verify that the value of atomic_t will be the same
in case of overflow if incremented in atomic and non-atomic manner

Signed-off-by: Alexander Razinkov <alexander.razinkov@syntacore.com>
2023-11-04 07:38:39 -04: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
Yonatan Schachter a7df77cd99 tests: byteorder: Add tests for sys_uint*_to_array macros
Add tests for sys_uint*_to_array macros to the byteorder suite.

Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
2023-09-28 07:39:09 -04:00
Anas Nashif 9f37ae902b tests/samples: set ram/rom limits on some samples/tests
Increase RAM requirements for some test, we have many exotic platforms
failing to link due to the size of the test.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-06-13 09:38:27 -04:00
Keith Packard b0585be1c4 tests/kernel/common: Add an explicit test using the minimal C library
When the default C library is switched to picolibc, we need some tests to
make sure things still build with the minimal C library.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-05-27 06:23:31 -04:00
Carlo Caione fecb03ecf8 bitarray: Fix mismatch checking when matching regions
We are currently reporting the wrong mismatching bits in in-between
bundles. Fix this and extend the test to cover the wrong case.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-05-25 16:31:23 -04:00
Anas Nashif 8dae3cd4d2 tests: kernel: common: fix where suites are defined
Remove definition of testcases in yaml file, those are now detected from
binary.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-05-25 04:44:11 -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
Alberto Escolar Piedras a2541d6c82 util: Replace all POSIX arch busy_waits with Z_SPIN_DELAY
A new Z_SPIN_DELAY() macro has been added which
can be used to reduce a bit the amount of noise
due to the POSIX arch need to break busy loops with
k_busy_wait().
Use it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-04 22:14:04 +01:00
Evgeniy Paltsev ae79de1930 ARC: MWDT add TLS support
Add thread local storage support for ARC MWDT toolchain.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-11-29 09:48:23 +01:00
Anas Nashif 17e8b58a45 tests: kernel: common: tag test correctly
Add missing kernel tag to a very basic kernel test.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-18 10:41:52 -05:00
Keith Packard 64c75d978e tests/kernel: Correct detection of picolibc long long support
Use the picolibc definition of _WANT_IO_LONG_LONG as that can only be set
when building the library, and not selected by the consumer.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-11-08 10:44:36 +01:00
Evgeniy Paltsev ac76c27af8 tests: arc: enable previously disabled tests on ARCv3 64bit platforms
Enable all cbprintf / logging related tests which were previously
disabled for qemu_arc_hs6x.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-10-31 11:22:12 +01:00
Daniel Leung 913c662062 tests: kernel/common: IRQ offload test if CONFIG_IRQ_OFFLOAD=y
This changes to compile the IRQ offload test only if
CONFIG_IRQ_OFFLOAD=y. For architectures that do not support
IRQ offload (or that developers with to disable IRQ offload
during bring-up), compiling the code would result in linking
errors.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-10-08 18:33:14 +02:00
Enjia Mai bafc258025 tests: kernel: common: remove the nop test case
The test case was originally designed for the coverage of
nop()/arch_nop() function. It is not very meaningful for
testing something but causing lots of false alarms on the
kernel/common test so far. Suggest removing this test case.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-09-21 13:38:09 -05: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
Christopher Friedt 13a2294f9d sys_clock: define NSEC_PER_MSEC
NSEC_PER_MSEC should be defined along with the rest of the
per-sec macros in sys_clock.h. Currently, it's defined
multiply in a few separate locations.

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
2022-09-01 16:29:25 -04:00
Martí Bolívar d5b0bd55e0 tests: kernel: common: adjust fudge factors
Loosen some timing constraints in order to hack arond spurious
failures in upstream Zephyr's CI while working on an unrelated task.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-08 10:44:41 +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
Tomislav Milkovic 0fe2c1fe90 everywhere: Fix legacy include paths
Any project with Kconfig option CONFIG_LEGACY_INCLUDE_PATH set to n
couldn't be built because some files were missing zephyr/ prefix in
includes
Re-run the migrate_includes.py script to fix all legacy include paths

Signed-off-by: Tomislav Milkovic <milkovic@byte-lab.com>
2022-07-18 16:16:47 +00:00
Guo Lixin 94936ca202 tests: kernel: common: move to new ztest API
Move tests/kernel/common/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-14 22:09:57 -04:00
Keith Packard 394a0485fb tests/kernel/common: Let picolibc pick a malloc heap size
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>
2022-06-30 10:33:24 +02:00
Anas Nashif dba3d31ddd tests: kernel: common: increase timeout
Some platforms need more time when under load, 60s are not enough.

Seen on hifive_unleashed.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-06-29 17:00:21 -04:00
Keith Packard 88ca3aca98 tests/kernel: Provide expected output for picolibc in printk test
Picolibc has subtly different output from the minimal libc as a result
of different handling for code built without real long long support.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-24 20:30:03 +02:00
Keith Packard f79eaba7e6 tests/kernel: Run common tests using picolibc
This runs the existing kernel common tests using picolibc as some of those
depend on libc functionality.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-23 09:16:32 +02:00
Nicolas Pitre f00573555b Z_POW2_CEIL: simplify implementation
Avoid potentially calling __builtin_clz() twice with non-constant
values. Also add a test for it.

Clang produces false positive vla warnings so disable them. GCC will
spot real vla's already.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-06-16 10:28:15 +02:00
Keith Packard d24e975a71 tests/kernel/common: Include errno_private.h
This ensures that we have a definition of z_errno in case
that isn't pulled in with errno.h

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-05-27 15:34:34 -07:00
Andy Ross 4b9a8a8471 tests/kernel/common: Extend nested_irq_offload case to do a context switch
Bug #45779 discovered an edge case with nested interrupts on Xtensa
where they might select an incorrect thread context to return to
instead of the (mandatory!) return to the outer interrupt context.

Cleverly adjust the nested_irq_offload to exercise this.  It now
creates a thread that it knows it will interrupt, then suspends that
thread from within the inner/nested interrupt.  This guarantees that
_current will be different on exit from the second interrupt, which is
the case that tripped up Xtensa.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-05-20 12:37:59 +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
Nazar Kazakov f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Daniel Leung 45940cf8cf tests: kernel/common: fix inadequate failing to thread context
The thread context test has insufficient checkings for failing
so add them:

() The variable rv for pass/fail is set but never checked. So
   add a check to fail the test if such indicated.
() Each thread's pass variable is set to TC_FAIL (== 1) and
   the check for successful thread execution simply checks
   if pass variable is not zero, which is always true. So
   change it so the check for failing condition is reasonable.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-02-24 08:38:38 -06:00
Carles Cufi e83a13aabf kconfig: Rename the TEST_EXTRA stack size option to align with the rest
All stack sizes should end with STACK_SIZE.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-22 08:23:05 -05:00
Andy Ross 59d5dc4dcf tests/kernel/common: Add nested irq_offload() test
Add a very simple test of the CONFIG_IRQ_OFFSET_NESTED feature that
exercises nested interrupts in a portable way.  It calls irq_offset()
from within a k_timer callback and validates that the return lands
back in the original interrupt successfully.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-02-21 22:10:03 -05:00
Mahesh Mahadevan 7e4d8c9cd5 tests: skip arch_nop test for ARM platforms
ARM does not guarantee the timing effects of NOP
instruction. Hence skip the test_nop test.
Fix for Issue#42666

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2022-02-21 21:54:53 -05:00
TOKITA Hiroshi da68cde759 tests: skip arch_nop test when machine timer uses divided sys clock
When the case machine timer clock uses the divided system clock,
k_cycle_get_32() can't measure accurately how many cycles elapsed.

For example, use the value as timer clock obtained by dividing
the system clock by 4.
In this case, measuring a duration with k_cycle_get32() has up to 3
(4-1) cycles systematic error.

To run this test, we need to insert an appropriate of nops
with consideration for the errors.
'nop' can not repeat with for loop.
Must insert as separated statement.
But we don't have a convenient function such as
BOOST_PP_REPEAT in C++.

At this time, Implementing a generic test is a bit difficult.
Skipping this test in the case.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2021-12-20 17:51:30 +01:00
Christopher Friedt ed7eec4c94 tests: kernel: atomics: expand atomic operations to 64-bit
This change updates the atomic tests to validate 32-bits on
32-bit architectures and 64-bits on 64-bit architectures.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-11-15 09:59:01 -05:00
Christopher Friedt 964b153f96 tests: clock: tests for k_cycle_get_64
This change adds tests for 64-bit cycle counters.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-11-08 13:41:53 -05:00
Enjia Mai 495d10234d tests: common: add test for ffs function
Add a testcase for find_msb_set() and find_lsb_set() functions.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-09-07 11:30:43 -04:00
Nicolas Pitre 5a384b9ea8 lib/os/cbprintf_nano.c: avoid sign extension on unsigned formats
There might be a sign extension when a long is promoted to
int_value_type and the former type is smaller than the later.
This produces the wrong output if the specified format is unsigned.

Let's avoid this problem by handling signed and unsigned cases
explicitly. When the type already matches int_value_type then the
compiler is smart enough to recognize the redundancy and removes
unneeded duplications automatically, meaning that the code will stay
small when code size matters.

A similar issue also existed in the restricted %llu case.
The fix is the same as above.

Those fixes exposed wrong results in the printk.c test with %llx
so fix that as well.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-09-02 19:37:06 -04:00
Naiyuan Tian 4cb1f0ef94 tests: common: fix typos in the commits
While reading the code, find typo in the code comment.
In file irq_offload.c, line 163.

Signed-off-by: Naiyuan Tian <naiyuan.tian@intel.com>
2021-08-26 06:54:55 -04:00