Commit graph

2589 commits

Author SHA1 Message Date
Nicolas Pitre 51a5986b04 tests: demand_paging: extend memory access patterns
Add the ability to touch memory in the opposite direction from one loop
to the next so to exercize the LRU eviction algorithm.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2024-06-14 18:58:02 -04:00
Rubin Gerritsen 8799ab1ec2 test: Apply semantic patch file ztest_strcmp.cocci
This patch file updates the use of assertion macros
comparing strings.

Command line used:
```
./scripts/coccicheck --mode=patch \
--cocci=scripts/coccinelle/ztest_strcmp.cocci tests/
```

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-06-14 19:25:42 +02:00
Dmitrii Golovanov 01dcb942c6 tests: kernel: timer_behavior_external: Fix a typo
Rename `do_analysys()` to `do_analysis()`.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-06-14 09:41:52 -04:00
Dmitrii Golovanov d72dd3562e tests: kernel: timer: Fix log capture on external tool testing
Fix incomplete test log capture when the external tool is used
and Twister Pytest Harness script ends without reading output
from the last test case running on the device.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-06-14 09:41:52 -04:00
Dmitrii Golovanov 014a0983fb tests: kernel: timer_behavior_external: Additional stats recording
Additional logging of kernel.timer.timer_behavior_external test case
statistics for timer drift, variance, etc. as JSON-formatted records
to make easier data collection and its further analysis.
These log records will be processed by the Twister Harness recording
feature which captures and parses timer statistics from the log output,
then composes it into twister.json and recording.csv files.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-06-14 09:41:52 -04:00
Dmitrii Golovanov dd67791857 tests: kernel: timer_behavior: Additional stats recording
Additional logging of kernel.timer.timer test case statistics for
timer drift, variance, etc. as JSON-formatted records to make easier
data collection and its further analysis.
These log records will be processed by the Twister Harness recording
feature which captures and parses timer statistics from the log output,
then composes it into twister.json and recording.csv files.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-06-14 09:41:52 -04:00
Andrzej Głąbek f73471eaf9 tests: timer_api: Use 64-bit integers in busy slew threshold calculation
32-bit multiplication overflows for the 130000 ppm value used currently
on Nordic SoCs and the duration that is configured to 100000 us.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2024-06-13 20:22:08 -04:00
Andrzej Głąbek 1cfd57177e tests: timer_api: Use busy slew threshold when checking remaining ticks
On Nordic SoCs, the clock that drives the system timer and the one that
is used in busy-waiting may be significantly skewed, so the test cases
that compare durations derived from those two clocks need to take into
account a proper threshold. After the `z_timeout_expires` function was
corrected in 3d29c9fe54, it turned out
that the threshold was missing in one check and the related test case
started to fail on nRF platforms. This patch adds that threshold there.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2024-06-13 20:22:08 -04:00
Yong Cong Sin 726fefd12c arch: riscv: stacktrace: implement arch_stack_walk()
Created the `arch_stack_walk()` function out from the original
`z_riscv_unwind_stack()`, it's been updated to support
unwinding any thread.

Updated the stack_unwind test case accordingly.

Increased the delay in `test_fatal_on_smp`, to wait
for the the fatal thread to be terminated, as stacktrace can
take a bit more time.

Doubled the kernel/smp testcase timeout from 60 (default) to
120s, as some of the tests can take a little bit more than 60s
to finish.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-13 16:46:48 -04:00
Nicolas Pitre d8a891b563 tests: demand_paging: add a test for k_mem_unmap()
Make sure k_mem_unmap() completes successfully on memory that is half
paged-out and such memory is no longer accessible afterwards.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2024-06-13 09:22:39 +02:00
Daniel Leung 7f6d600dd6 kernel: mm: rename z_num_pagefaults_get to k_mem_num_*
This is part of a series of moving memory management related
stuff out of the Z_ namespace and into its own namespace.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-06-12 21:13:26 -04:00
Daniel Leung 9064652db9 tests: mem_protect/syscalls: exclude board numaker_m2l31ki
The board defconfig forces CONFIG_USERSPACE to be disabled
due to small number of available MPU regions which are not
enough for userspace testing.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-06-12 21:13:26 -04:00
Daniel Leung 54af5dda84 kernel: mm: rename z_page_frame_* to k_mem_page_frame_*
Also any demand paging and page frame related bits are
renamed.

This is part of a series to move memory management related
stuff out of the Z_ namespace into its own namespace.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-06-12 21:13:26 -04:00
Daniel Leung a459cdf51e kernel: mm: rename Z_FREE_VM_START to K_MEM_VM_FREE_START
This is part of a series to move memory management related
stuff from Z_ namespace into its own namespace.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-06-12 21:13:26 -04:00
Daniel Leung db9d3134c5 kernel: mm: rename Z_MEM_PHYS/VIRT_ADDR to K_MEM_*
This is part of a series to move memory management functions
away from the z_ namespace and into its own namespace. Also
make documentation available via doxygen.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-06-12 21:13:26 -04:00
Daniel Leung 552e29790d kernel: mm: rename z_phys_un/map to k_mem_*_phys_bare
This renames z_phys_map() and z_phys_unmap() to
k_mem_map_phys_bare() and k_mem_unmap_phys_bare()
respectively. This is part of the series to move memory
management functions away from the z_ namespace.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-06-12 21:13:26 -04:00
Aksel Skauge Mellbye fee86aecaa boards: silabs: Consistently name radio boards
Rename all Silicon Labs radio boards to always use the official kit name of
the kit containing only the radio board as board target name. Disentangle
boards using Series 1 and Series 2 SoCs that have almost nothing in common
in terms of devicetree content, but still occupied the same directory.

As part of the initial HWMv2 port, all radio boards were merged into a
single target efr32_radio, using the SoC as a board qualifier to target
specific boards. This was unfortunate, as the SoC name is not sufficient
to identify a specific board -- the same SoC may be used on multiple
different boards. This commit reinstates every radio board as an individual
board target.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2024-06-12 12:52:28 -04:00
Nicolas Pitre 2871c87aae tests: poll: fix misconstructed k_poll_event test
Since commit 0c23cf94a4 ("include/kernel: check type of object passed
to K_POLL_EVENT_INITIALIZER") it is no longer possible to use arbitrary
type literals with the initializer macro. Misconstructing a k_poll_event
type for test purpose must be done explicitly.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2024-06-12 10:24:21 +02:00
Yassine El Aissaoui bb770c5965 samples: tests: bluetooth: Add support for frdm_rw612
Adding bt_tester support.

Adding bt_tester app build
with Twister for frdm_rw612 board

Fix failing tests/samples due to unsufficent MPU ressources
by releasing unnecessary MPU regions.

Twister builds added on peripheral/central ht and
enabled Power manager on those examples to cover
the CI builds with PM enabled.

Signed-off-by: Yassine El Aissaoui <yassine.elaissaoui@nxp.com>
2024-06-10 07:02:06 -07:00
Daniel Leung 86a63627b0 tests: kernel/queue: config overlay for intel_adsp/ace30_ptl
This sets CONFIG_MAX_THREAD_BYTES to 3 as the tests need a few
more bits to build for board intel_adsp/ace30_ptl.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-06-06 20:06:11 -04:00
Daniel Leung f50ac58b1d tests: mutex/sys_mutex: config overlay for intel_adsp/ace30_ptl
This sets CONFIG_MAX_THREAD_BYTES to 3 as the tests need a few
more bits to build for board intel_adsp/ace30_ptl.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-06-06 20:06:11 -04:00
Daniel Leung 1a93191f45 tests: mem_protect/sys_sem: config for intel_adsp/ace30_ptl
This sets CONFIG_MAX_THREAD_BYTES to 3 as the tests need a few
more bits to build for board intel_adsp/ace30_ptl.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-06-06 20:06:11 -04:00
Peter Mitsis 48285cb6b8 tests: Add IPI_OPTIMIZE tests
Adds several tests to verify that IPIs can be appropriately
targeted to specific CPUs.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2024-06-04 22:35:54 -04:00
Peter Mitsis 0bcdae2c62 kernel: Add CONFIG_ARCH_HAS_DIRECTED_IPIS
Platforms that support IPIs allow them to be broadcast via the
new arch_sched_broadcast_ipi() routine (replacing arch_sched_ipi()).
Those that also allow IPIs to be directed to specific CPUs may
use arch_sched_directed_ipi() to do so.

As the kernel has the capability to track which CPUs may need an IPI
(see CONFIG_IPI_OPTIMIZE), this commit updates the signalling of
tracked IPIs to use the directed version if supported; otherwise
they continue to use the broadcast version.

Platforms that allow directed IPIs may see a significant reduction
in the number of IPI related ISRs when CONFIG_IPI_OPTIMIZE is
enabled and the number of CPUs increases.  These platforms can be
identified by the Kconfig option CONFIG_ARCH_HAS_DIRECTED_IPIS.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2024-06-04 22:35:54 -04:00
Yong Cong Sin e54b27b967 arch: define struct arch_esf and deprecate z_arch_esf_t
Make `struct arch_esf` compulsory for all architectures by
declaring it in the `arch_interface.h` header.

After this commit, the named struct `z_arch_esf_t` is only used
internally to generate offsets, and is slated to be removed
from the `arch_interface.h` header in the future.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-04 14:02:51 -05:00
Ederson de Souza 7f0b5edd8c arch/x86: Make irq_offload SMP-safe on x86_64
The irq_offload mechanism was using the same entry of the IDT vector for
all CPUs on SMP systems. This caused race conditions when two CPUs were
doing irq_offload() calls.

This patch addresses that by adding one indirection layer: the
irq_offload() now sets a per CPU entry with the routine and parameter to
be run. Then a software interrupt is generated, and a default handler
will do the appropriate dispatching.

Finally, test "kernel/smp_abort" is enabled for x86 as it should work
now.

Fixes #72172.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2024-06-04 07:57:06 +02:00
Hess Nathan 209a3bd40a coding guidelines: comply with MISRA Rule 11.8
- modified parameter types to receive a const pointer when a
  non-const pointer is not needed

Signed-off-by: Hess Nathan <nhess@baumer.com>
2024-06-03 16:09:51 -04:00
TaiJu Wu 18d9ba4b82 test: Add a testcase for cpu affinity
Pin thread to a specific cpu. Once thread gets cpu, check
the cpu id is correct and then thread will give up cpu.

Signed-off-by: TaiJu Wu <tjwu1217@gmail.com>
2024-05-31 08:07:46 +02:00
Marcin Szymczyk 68c48cd116 tests: kernel: interrupt: account for table offset
When verifying sw_isr_table, take into account custom offset,
like `CONFIG_RISCV_RESERVED_IRQ_ISR_TABLES_OFFSET` in some
RISC-V SoCs.

Relates to #71948 and #73232.

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
2024-05-29 11:58:44 +02:00
Yong Cong Sin bbe5e1e6eb build: namespace the generated headers with zephyr/
Namespaced the generated headers with `zephyr` to prevent
potential conflict with other headers.

Introduce a temporary Kconfig `LEGACY_GENERATED_INCLUDE_PATH`
that is enabled by default. This allows the developers to
continue the use of the old include paths for the time being
until it is deprecated and eventually removed. The Kconfig will
generate a build-time warning message, similar to the
`CONFIG_TIMER_RANDOM_GENERATOR`.

Updated the includes path of in-tree sources accordingly.

Most of the changes here are scripted, check the PR for more
info.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-28 22:03:55 +02:00
Marcin Szymczyk 8999446ab8 tests: kernel: gen_isr_table: add support for nRF54L15 FLPR
Align testcase to nRF54L15 FLPR.
Follow up of #71948.

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
2024-05-27 08:15:46 -07:00
Yong Cong Sin dcaf217336 irq: multilevel: add APIs with level as argument
Add APIs that accept an additional `level` argument, and use
that to call the respective functions. In some cases this can
reduce code complexity, especially when the level isn't known
at build time.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-25 11:24:32 +03:00
Yong Cong Sin c5f5b964c1 arch: sw_isr: revamp multi-level interrupt architecture
Previously the multi-level irq lookup table is generated by
looping through the devicetree nodes using macros & Kconfig,
which is hard to read and flimsy.

This PR shifts the heavy lifting to devicetree & DT macros such
that an interrupt controller driver, which has its info in the
devicetree, can register itself directly with the multi-level
interrupt architecture, which is more straightforward.

The previous auto-generated look up table with macros is now
moved in a file of its own. A new compatibility Kconfig:
`CONFIG_LEGACY_MULTI_LEVEL_TABLE_GENERATION` is added and
enabled by default to compile the legacy look up table for
interrupt controller drivers that aren't updated to support the
new architecture yet.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-25 11:24:32 +03:00
Yong Cong Sin 84da6c8e6c test: gen_isr_table: exclude NRFX_CLIC from riscv_no_direct
VPR cores CLIC supports vectored mode only and can't be
disabled. Filter out `CONFIG_NRFX_CLIC` to prevent build
error.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-25 11:24:32 +03:00
Yassine El Aissaoui 4a755a3157 samples: tests: bluetooth: Add support for rd_rw612_bga
Adding bt_tester support.

Adding bt_tester app build
with Twister for rd_rw612_bga board

Fix failing tests/samples due to unsufficent MPU ressources
by releasing unnecessary MPU regions.

Disable twister build on samples that are not meant to
be supported on this board, so exclude it from the test cases.

Update peripheral/central ht sample.yaml files
to test build for rd_rw612_bga.

Signed-off-by: Axel Le Bourhis <axel.lebourhis@nxp.com>
Signed-off-by: Yassine El Aissaoui <yassine.elaissaoui@nxp.com>
2024-05-25 11:23:04 +03:00
Dmitrii Golovanov d38913ba48 tests/kernel/timer/timer_behavior/pytest: aligh grpcio version
Align grpcio version with logic2-automation package fixing its fail
on Channel.unary_unary() call with missing _registered_method argument..

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-05-24 09:54:05 -05:00
Flavio Ceolin 95dde52b1e tests: dynamic_thread_stack: Check thread stack permission
Check if a user thread is capable of free another thread stack.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-05-21 20:54:56 -04:00
Daniel Leung 8426a05e0e tests: mem_protect/userspace: use kconfig for other stack tests
This uses the newly introduced CONFIG_MEM_DOMAIN_ISOLATED_STACKS
to determine whether to proceed with the tests to access other
threads' stacks. This provides more precise control on when to
run or skip these tests.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-05-21 20:53:09 -04:00
Lucas Romero 3f50197a90 lib: bitarray: add method to find nth bit set in region
This is part one of several changes to add more methods to the bitarray api
so that it can be used for broader usecases, specifically LoRaWAN forward
error correction.

Signed-off-by: Lucas Romero <luqasn@gmail.com>
2024-05-21 16:44:38 -04:00
Lucas Romero 752d3c529e lib: bitarray: add method to xor two bitarrays
This is part one of several changes to add more methods to the bitarray api
so that it can be used for broader usecases, specifically LoRaWAN forward
error correction.

Signed-off-by: Lucas Romero <luqasn@gmail.com>
2024-05-21 16:44:38 -04:00
Lucas Romero c5e5686805 lib: bitarray: add method to count bits set in region
This is part one of several changes to add more methods to the bitarray api
so that it can be used for broader usecases, specifically LoRaWAN forward
error correction.

Signed-off-by: Lucas Romero <luqasn@gmail.com>
2024-05-21 16:44:38 -04:00
Alberto Escolar Piedras a1576af7af tests/kernel timer_api: Test absolute timers with loosing ticks
Let's also explicitly test that absolute timeouts trigger
at the correct time, even if the kernel has not seen
system clock timer announcements for a while.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-05-16 18:56:14 -04:00
Pieter De Gendt e791e7637f tests: kernel: device: Add CMAKE_LINKER_GENERATOR test case
Add a test case entry with CONFIG_CMAKE_LINKER_GENERATOR enabled.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-05-13 09:46:13 +02:00
Alberto Escolar Piedras 22c83f0f97 tests/kernel/context: Detect spurious wakes during timeout check
In 972a4d9f6f
the test was relaxed to allow a possible parallel thread
waking the CPU during the idle timeout checks.

How this was done though, a system timer driver
which wakes the kernel spuriously a bit before the
correct deadline would not be detected, even
though it should.

Let's fix this, ensuring the timer has been
called when we check the wake time in inside the
expected range.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-05-07 17:56:50 -04:00
Marcin Szymczyk 8742e24760 tests: kernel: interrupt: nested_irq: support nRF54L15 FLPR CLIC
Add support for VPR CLIC to `nested_irq` kernel test.
Verified on nRF54L15 FLPR for now.

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
2024-05-06 19:06:19 +02:00
Marcin Szymczyk fd79676c16 tests: kernel: interrupt: account for custom RISCV IRQ offset
`CONFIG_RISCV_RESERVED_IRQ_ISR_TABLES_OFFSET` offsets IRQ in
vector table, align test to this functionality.

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
2024-05-06 19:06:19 +02:00
Pieter De Gendt f147a5fec2 spelling: Replace occurrences of "iff" with "if and only if"
Spell checking tools do not recognize "iff", replace with "if and only if".
See https://en.wikipedia.org/wiki/If_and_only_if

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-05-06 14:58:08 +01:00
Alberto Escolar Piedras ba4bbe91b4 Revert "tests: kernel: update test case with sys_clock_hw_cycles_per_sec"
This reverts commit fd8ca83e9a.

https://github.com/zephyrproject-rtos/zephyr/pull/69705
Introduced a regression in main in which
tests/subsys/logging/log_timestamp
started failing. (See
https://github.com/zephyrproject-rtos/zephyr/issues/72344
for more info).
Let's revert the PR. It can be submitted after with the issue
fixed.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-05-06 14:52:29 +03:00
Najumon B.A fd8ca83e9a tests: kernel: update test case with sys_clock_hw_cycles_per_sec
update test case with sys_clock_hw_cycles_per_sec() api to retrieve
system clock frequency (HW cycle per sec) at runtime or statically

Signed-off-by: Najumon B.A <najumon.ba@intel.com>
2024-05-04 13:24:12 +03:00
Peter Mitsis 283d4133fa tests: thread abort deadlock scenario
Adds a test to verify that a series of k_thread_abort() issued from
ISRs do not cause a deadlock.

Filtered on x86 as the x86_64 irq_offload() implementation isn't
SMP-safe.  See #72172

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2024-05-02 13:55:03 -04:00