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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
`_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>
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>