Commit graph

2758 commits

Author SHA1 Message Date
Robin Kastberg
20360ce95b tests: kernel: Don't use VLA in pipe_api test.
In the current pipe_api test file we inadvertantly use VLA.
Toolchains are allowed by standard to allocate VLA on
heap for example. Therefore in my opinion we shouldn't
use VLA atleast in kernel+kernel tests.

Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2025-02-05 14:57:49 +01:00
Tom Hughes
81f5581a86 tests: kernel: thread_apis: Fix -Wsometimes-uninitialized warning
Building kernel.threads.apis with clang warns:

tests/kernel/threads/thread_apis/src/main.c:362:6: error: variable 'ret'
is used uninitialized whenever 'if' condition is true
[-Werror,-Wsometimes-uninitialized]
        if (m == ISR_ALREADY_EXIT || m == ISR_RUNNING) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests/kernel/threads/thread_apis/src/main.c:380:6: note: uninitialized
use occurs here
        if (ret != 0) {
            ^~~
tests/kernel/threads/thread_apis/src/main.c:362:2: note: remove the 'if'
if its condition is always false
        if (m == ISR_ALREADY_EXIT || m == ISR_RUNNING) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests/kernel/threads/thread_apis/src/main.c:362:6: error: variable 'ret'
is used uninitialized whenever '||' condition is true
[-Werror,-Wsometimes-uninitialized]
        if (m == ISR_ALREADY_EXIT || m == ISR_RUNNING) {
            ^~~~~~~~~~~~~~~~~~~~~
tests/kernel/threads/thread_apis/src/main.c:380:6: note: uninitialized
use occurs here
        if (ret != 0) {
            ^~~
tests/kernel/threads/thread_apis/src/main.c:362:6: note: remove the '||'
if its condition is always false
        if (m == ISR_ALREADY_EXIT || m == ISR_RUNNING) {
            ^~~~~~~~~~~~~~~~~~~~~~~~
tests/kernel/threads/thread_apis/src/main.c:329:9: note: initialize the
variable 'ret' to silence this warning
        int ret;
               ^
                = 0

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-02-05 05:40:51 +01:00
Kalle Kietäväinen
52b8e3d370 tests: kernel: metairq: Ensure meta-IRQ can preempt a cooperative thread
The intention of the test is to have a meta-IRQ preempt a cooperative
thread, then ensure the same cooperative thread is resumed back to instead
of a higher priority thread. Thus, the test needs to assert that the lower
priority cooperative thread is not yet complete when it makes the higher
priority thread ready to run.

This change reveals bugs like #80574, where the meta-IRQ is unable to
preempt a cooperative thread.

Signed-off-by: Kalle Kietäväinen <kalle.kietavainen@silabs.com>
2025-02-04 12:03:20 +01:00
Piotr Kosycarz
54370d7530 tests: kernel: timer: timer_behavior: add tags
Missing tags.

Signed-off-by: Piotr Kosycarz <piotr.kosycarz@nordicsemi.no>
2025-01-30 02:02:06 +01:00
Jamie McCrae
978f55926f tests: kernel: pipe: deprecated: Fix test wrongly passing paramater
Fix these tests so that the parameters are correctly passed to
other parts of the build

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-01-28 12:00:34 +01:00
Krzysztof Chruściński
04e8d08e04 tests: kernel: timer: timer_api: Tweak test_timer_remaining
Test test_timer_remaining is comparing time captured by k_busy_wait and
k_timer_remaining_ticks. Test was accepting 1 tick difference between
those two. If system clock frequency is low (e.g. 100 Hz) 1 tick is a
long time but if system clock is high then 1 tick may not cover for
processing latency. Instead of using fixed 1 tick test is now converting
100 us to ticks (ceiling) to cover for cases where system clock is high.
100 us processing latency time is an arbitrary value.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-01-24 08:38:48 +01:00
Daniel Leung
32f5ef5892 tests: kernel/msgq_api: join threads after each test
On SMP systems, threads going through k_thread_abort() may still
be running while the test moves on to the next one. This creates
some interferences and may result in the next test failing. So
after each test, we need to do k_thread_join() on those threads
to make sure they are no longer active.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2025-01-22 20:47:05 +01:00
Alberto Escolar Piedras
1ce3898832 tests pipe_api: Fix unitialized variable warning
Fix so the compiler does not throw a warning thinking that those
buffers may be used unitialized inside k_pipe_write/read().

Note clang does not the array size being of a variable size and
initialized as it throws a
"error: variable length array folded to constant array as an extension"

The issue was discovered with with gcc 14.2

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-01-20 20:55:18 +01:00
Måns Ansgariusson
0572f1f098 tests: Update tests to use new k_pipe API
Update tests to use the reworked k_pipe API.

Signed-off-by: Måns Ansgariusson <Mansgariusson@gmail.com>
2025-01-17 19:43:44 +01:00
Måns Ansgariusson
6782c5381d tests: kernel: pipe: Add new test cases for pipe API rework
This commit adds new test cases for the pipe API rework.
* basic.c: Sanity check for pipe operations.
* concurrency.c: Test pipe operations with multiple threads.
* stress.c: Test pipe operations under stress conditions.

And moves the old pipe test cases to the deprecated folder.

Signed-off-by: Måns Ansgariusson <Mansgariusson@gmail.com>
2025-01-17 19:43:44 +01:00
Joakim Andersson
7faafda9e7 tests: kernel: Test endian-specific buffer convert and copy functions
Test endian-specific buffer convert and copy functions.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2025-01-17 13:56:33 +01:00
Georgios Vasilakis
37c23deea1 tests: kernel: Increase MAX_THREAD_BYTES to 6
Increase the MAX_THREAD_BYTES from 5->6 to accomodate
for devices with an increased number of threads in the
tests schedule_api and dynamic_thread_stack.

Signed-off-by: Georgios Vasilakis <georgios.vasilakis@nordicsemi.no>
2025-01-17 10:42:10 +01:00
Fin Maaß
b10781ba45 arch: common: be able to use ROM_START_OFFSET on RISCV
be able to use ROM_START_OFFSET on RISCV.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-01-17 09:07:45 +01:00
Krzysztof Chruściński
5e2b9980bc tests: kernel: timer: timer_behavior: Reduce tick frequency(nrf54l09pdk)
Test test_one_tick_timer_train was failing due not being able to
 execute enough 1 tick timeouts. Decrease system ticks frequency
 to make the test pass.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-01-16 22:40:16 +01:00
Peter Mitsis
1e87400bea tests: thread_apis: Add custom unmapped address
Adds a custom unmapped address for qemu_cortex_r5.

Fixes #79627

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2025-01-16 22:40:00 +01:00
Peter Mitsis
faef1ac9b6 tests: thread_apis: Make unmapped address configurable
Although many platforms may have an unmapped address in common,
this address will not be the same for all platforms. This commit
makes such an address configurable to get better coverage.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2025-01-16 22:40:00 +01:00
Dmitrii Golovanov
e63a513a93 tests: Adjust to Twister changes in recording feature
Adjust testcase.yaml files to changes in Twister schema which
now allows multiple recording patterns ('record: regex:').

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2025-01-16 22:38:51 +01:00
Krzysztof Chruściński
0359f37263 tests: kernel: gen_isr_table: Fix test for nRF VPR targets
Test was using interrupt lines which does not exist on nRF VPR
targets. nRF54Lx FLPR has interrupts >= 16 and nRF54Hx PPR does
not have interrupt 17. Added configuration which works for
nrf54h20_cpuppr and nrf54lx_flpr.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-01-15 15:05:38 +01:00
Lucien Zhao
5c3efe1e68 samples: userspace: shared_mem: remove mimxrt700_evk cm33 cores
The number of mpu regions that can be configured is less than four cases.
Therefore, only remove this case on cm33 cores, failed log show below:
"num_parts of 4 exceeds maximum allowable partitions (3)"

samples: kernel: mem_protect: userspace: remove mimxrt700_evk cm33 cores

The maximum number of partitions is less than the number of partitions
currently required, causing case to be unable to apply for or delete
excess regions.

Signed-off-by: Lucien Zhao <lucien.zhao@nxp.com>
2025-01-14 17:56:53 +01:00
Robin Kastberg
3f3c66f664 tests: kernel: timer_behaviour shouldnt use fabs
Currently the timer_behavior test uses fabs.
Since the C library functions being used in the kernel
is restricted in Rule A.4 in the Coding Standard
We should probably not use these functions in tests either.

Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2025-01-14 15:39:38 +01:00
Adam Kondraciuk
eb7e947d78 tests: kernel: Fix for nRF54H20
Fix failing tests for nRF54H20 target.

Signed-off-by: Adam Kondraciuk <adam.kondraciuk@nordicsemi.no>
2025-01-14 15:38:32 +01:00
Robin Kastberg
75daa436ec tests: kernel: workq_stop uninitialized variable
test_k_workqueue_stop uses an uninitialized variable, causing
sporadic test failures.

Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
2025-01-14 13:25:35 +01:00
Nicolas Pitre
46aa6717ff Revert "arch: deprecate _current"
Mostly a revert of commit b1def7145f ("arch: deprecate `_current`").

This commit was part of PR #80716 whose initial purpose was about providing
an architecture specific optimization for _current. The actual deprecation
was sneaked in later on without proper discussion.

The Zephyr core always used _current before and that was fine. It is quite
prevalent as well and the alternative is proving rather verbose.
Furthermore, as a concept, the "current thread" is not something that is
necessarily architecture specific. Therefore the primary abstraction
should not carry the arch_ prefix.

Hence this revert.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2025-01-10 07:49:08 +01:00
Anas Nashif
08ed0f3282 tests: kernel: common: use integration_toolchains
Use new keyword integration_toolchains to build test using additional
toolchains.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-01-08 12:58:59 +01:00
Simone Orru
2bd101132e kernel: Add tests for k_heap_calloc
Add tests for the k_heap_calloc function.

Signed-off-by: Simone Orru <simone.orru@secomind.com>
2024-12-30 17:32:03 +01:00
Peter Mitsis
31ebd6036a tests: Test k_reschedule() with deadline scheduler
Setting a deadline is not a schedule point. This makes it a
perfect place to verify the behavior of the new k_reschedule()
routine at both thread and ISR level.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2024-12-24 04:22:51 +01:00
Gerard Marull-Paretas
179576d059 tests: add missing CONFIG_GPIO=y
All tests using the GPIO API must enable the CONFIG_GPIO Kconfig
option.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2024-12-20 03:17:25 +01:00
Daniel Leung
f786ecc075 tests: mem_protect/mem_map: add data cache manipulations
This adds data cache manipulations, flushing and invalidation,
to the tests where buffer content are being written and
compared. These tests map different virtual pages to the same
physical pages, and write to one of the mapped virtual
addresses. Some SoCs may cache the virtual address separately
and writes to one virtual address will not be reflected to
another virtual address, this failing the comparison. So we
need to manually flush the cache after writing to the buffer,
and invalidating cache before reading. Note that not all reads
and writes need this treatment as some of them only needs to
test for access permissions, and not the memory content.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-12-19 21:54:16 +01:00
Daniel Leung
352fed6b21 tests: mem_protect/mem_map: limit CPUs to 1 if incoherent cache
For CPUs with incoherent cache under SMP, the tests to read/write
buffer (... majority of tests here) may not work correctly if
the test thread jumps between CPUs. So use the test infrastructure
to limit the test to 1 CPU.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-12-19 21:54:16 +01:00
Peter Mitsis
5710e034e7 kernel: Introduce _THREAD_SLEEPING state bit
At the present time, Zephyr does has overlap between sleeping and
suspending. Not only should sleeping and suspended be orthogonal
states, but we should ensure users always employ the correct API.
For example, to wake a sleeping thread, k_wakeup() should be used,
and to resume a suspended thread, k_thread_resume() should be used.
However, at the present time k_thread_resume() can be used on a
thread that called k_sleep(K_FOREVER). Sleeping should have nothing
to do with suspension.

This commit introduces the new _THREAD_SLEEPING thread state along
with some prep-work to facilitate the decoupling of the sleeping and
suspended thread states.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2024-12-18 18:17:03 +01:00
William Tambe
f510314a28 tests: guard variable used only with CONFIG_TRACE_SCHED_IPI
Change to prevent build failure when CONFIG_SCHED_IPI_SUPPORTED is
defined and CONFIG_TRACE_SCHED_IPI is not.

Signed-off-by: William Tambe <williamt@cadence.com>
2024-12-17 20:54:48 +01:00
TaiJu Wu
e8a5e97385 test: k_msgq_put should trigger reschedule
In this test, low priority thread call `k_msgq_put` should
trigger reschedule.

Signed-off-by: TaiJu Wu <tjwu1217@gmail.com>
2024-12-14 01:04:43 +01:00
Måns Ansgariusson
8934b810cc tests: kernel: Add support for stopping workqueues
This patch adds tests for stopping workqueues.

Signed-off-by: Måns Ansgariusson <Mansgariusson@gmail.com>
2024-12-12 11:07:39 +01:00
Valerio Setti
522b1f2bba Revert "tests: disable NRF5 entropy driver on some bsim/qemu tests"
This reverts commit e0fcb8552428fb45164ea2b4271b3b0206695b7f.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-12-12 00:15:39 +00:00
Valerio Setti
22e30e04f5 tests: disable NRF5 entropy driver on some bsim/qemu tests
CONFIG_ENTROPY_GENERATOR is now enabled by default as soon as
"zephyr,entropy" is set in the device-tree. Since the sub-Kconfig
CONFIG_ENTROPY_NRF5_RNG is also enabled by default on nrf boards,
this means that the driver is pulled in the build and intialized
at boot. This might cause runtime issues during some IRQ/kernel
tests, so it's better to remove "zephyr,entropy" on these tests.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-12-10 08:05:33 +01:00
Daniel Leung
b5b00134c5 tests: demand_paging/mem_map: move malloc config to prj.conf
Both tests set CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=0 so extract
it to prj.conf. The tests require malloc arena size to be 0 to
run successful. By refactoring the config, it is now able to
with west build and still passing.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-12-07 16:01:10 +00:00
Dmytro Firsov
b3758a787c tests: kernel: exclude xenvm with GICv3 from device tests
The issue with mentioned test for GICv3 version of xenvm virtual
board is the same as for regular xenvm - device tree overlay for this
test overrides #address-cells and #size-cells property for original
device tree file (from 0x2 to 0x1), which leads to incorrect DT parsing
by actual Xen drivers. This causes build errors, so test should be
skipped for GICv3 platform too.

Same issue for regular xenvm was fixed by commit 40fe36669c ("tests:
kernel: exclude xenvm from device tests"). Issue for GICv3 appeared
after migrating to HWMv2.

Signed-off-by: Dmytro Firsov <dmytro_firsov@epam.com>
2024-12-05 22:09:31 +01:00
Gerard Marull-Paretas
d4a67e321b samples, tests: remove usage of space-separated lists
Convert them to native YAML lists. Support for space-separated
lists was deprecated in Twister a long time ago.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2024-12-04 14:14:53 -05:00
Akaiwa Wataru
1bb5c34f98 tests: kernel/sched: 32-bit tick wraparound during k_sleep() execution
This test reproduce the issue: https://github.com/zephyrproject-rtos/zephyr/issues/79863

In this test, instead of waiting the 32-bit tick wraparound for several
days, patching the kernel internal tick with the test API.

Signed-off-by: Akaiwa Wataru <akaiwa@sonas.co.jp>
2024-12-03 02:37:03 +01:00
Pieter De Gendt
6d178f9cd9 drivers: gpio: Place API into iterable section
Add wrapper DEVICE_API macro to all gpio_driver_api instances.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-12-02 22:05:59 +00:00
Krzysztof Chruściński
51b6f66fce tests: kernel: timer: timer_behavior: Reduce tick frequency(nrf54l20pdk)
Test test_one_tick_timer_train was failing due not being able to
execute enough 1 tick timeouts. Decrease system ticks frequency
to make the test pass.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-12-02 14:23:22 +01:00
Flavio Ceolin
4f33729ee0 tests: mem_protect/stackprot: Use __noinline attribute
Use Zephyr definition for noinline attribute.

Signed-off-by: Flavio Ceolin <flavio.ceolin@gmail.com>
2024-11-30 01:04:11 +01:00
Flavio Ceolin
f9d17b4233 tests: mem_protect/protection: Use __noinline attribute
Use Zephyr definition for noinline attribute.

Signed-off-by: Flavio Ceolin <flavio.ceolin@gmail.com>
2024-11-30 01:04:11 +01:00
Andy Ross
7cdf40541b kernel/sched: Eliminate PRESTART thread state
Traditionally threads have been initialized with a PRESTART flag set,
which gets cleared when the thread runs for the first time via either
its timeout or the k_thread_start() API.

But if you think about it, this is no different, semantically, than
SUSPENDED: the thread is prevented from running until the flag is
cleared.

So unify the two.  Start threads in the SUSPENDED state, point
everyone looking at the PRESTART bit to the SUSPENDED flag, and make
k_thread_start() be a synonym for k_thread_resume().

There is some mild code size savings from the eliminated duplication,
but the real win here is that we make space in the thread flags byte,
which had run out.

Signed-off-by: Andy Ross <andyross@google.com>
2024-11-27 10:38:05 -05:00
Pieter De Gendt
f29203d575 tests: kernel: device: Add API sections tests
Add tests for the subsystem_api to validate runtime API section checks.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-27 08:15:22 +01:00
Anas Nashif
5b29fff725 tests: workqueue: avoid filters
Use Kconfig to configure watchdog instead of using expensive filters.

Also disable CONFIG_TEST_HW_STACK_PROTECTION for this test so we do not
have to create special cases.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-11-25 21:51:36 +01:00
Anas Nashif
a8b788d344 tests: mem_map: reduce runtime filters
Improve CI performance improving filtering and coverage selection.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-11-25 21:51:36 +01:00
Pieter De Gendt
bf2db7afc0 python: Format and sort imports
ruff check --select I001 --fix applied to all python files that had
this as only issue.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-25 10:07:13 +01:00
Yong Cong Sin
b1def7145f arch: deprecate _current
`_current` is now functionally equals to `arch_curr_thread()`, remove
its usage in-tree and deprecate it instead of removing it outright,
as it has been with us since forever.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-11-23 20:12:24 -05:00
Anas Nashif
28796076d8 tests: kernel: common: optimize filters
Optimize filters and remove build_on_all, this option is already used in
the synchronization sample which has more coverage on small platforms.

Since we only build, it does provide basic sanitcheck for the kernel as
well.

This reduces testplan on PRs and push events by almost 1000 entries that
would only be built or filtered at runtime.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-11-21 19:22:35 -05:00