Commit Graph

2597 Commits

Author SHA1 Message Date
Krzysztof Chruściński 44c2b19d5e tests: kernel: timer: behavior: pytest: Adjust max stddev
Like in C test. If MAX STDDEV is lower than single clock cycle then
set it to a single clock cycle.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-07-09 19:02:51 +02:00
Krzysztof Chruściński 1968cdf556 tests: kernel: timer: timer_behavior: Tweak expected std deviation
If frequency of the system clock is lower then deviation may exceed
default value (10us). Instead of adjusting the default value, test is
rounding up expected standard deviation to a single clock cycle.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-07-09 19:02:51 +02:00
Jordan Yates 243eb36b18 everywhere: reindent `.overlay` files with tabs
`checkpatch.pl` requires that dts sources are indented with tabs,
fix all the spaces that slipped in while checkpatch wasn't watching.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-26 15:59:44 +02:00
Nicolas Pitre a53ddff3b6 tests: demand_paging: touch memory with more useful content
When content validation fails it is rather difficult to figure out the
cause if some meaningless byte mismatches another meaningless byte.
Let's store each memory location with its own virtual address so if a
mismatch occurs when reading it back it is obvious where it comes from.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2024-06-25 21:19:40 -04:00
Keith Packard 0491000c16 tests/kernel: Add test for constructors in C
Make sure constructors are run even when not using C++.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-06-25 19:14:37 -04:00
Lingao Meng 302422ad9d everywhere: replace double words
import os
import re

common_words = set([
    'about', 'after', 'all', 'also', 'an', 'and',
     'any', 'are', 'as', 'at',
    'be', 'because', 'but', 'by', 'can', 'come',
    'could', 'day', 'do', 'even',
    'first', 'for', 'get', 'give', 'go', 'has',
    'have', 'he', 'her',
    'him', 'his', 'how', 'I', 'in', 'into', 'it',
    'its', 'just',
    'know', 'like', 'look', 'make', 'man', 'many',
    'me', 'more', 'my', 'new',
    'no', 'not', 'now', 'of', 'one', 'only', 'or',
    'other', 'our', 'out',
    'over', 'people', 'say', 'see', 'she', 'so',
    'some', 'take', 'tell', 'than',
    'their', 'them', 'then', 'there', 'these',
    'they', 'think',
    'this', 'time', 'two', 'up', 'use', 'very',
    'want', 'was', 'way',
    'we', 'well', 'what', 'when', 'which', 'who',
    'will', 'with', 'would',
    'year', 'you', 'your'
])

valid_extensions = set([
    'c', 'h', 'yaml', 'cmake', 'conf', 'txt', 'overlay',
    'rst', 'dtsi',
    'Kconfig', 'dts', 'defconfig', 'yml', 'ld', 'sh', 'py',
    'soc', 'cfg'
])

def filter_repeated_words(text):
    # Split the text into lines
    lines = text.split('\n')

    # Combine lines into a single string with unique separator
    combined_text = '/*sep*/'.join(lines)

    # Replace repeated words within a line
    def replace_within_line(match):
        return match.group(1)

    # Regex for matching repeated words within a line
    within_line_pattern =
	re.compile(r'\b(' +
		'|'.join(map(re.escape, common_words)) +
		r')\b\s+\b\1\b')
    combined_text = within_line_pattern.
		sub(replace_within_line, combined_text)

    # Replace repeated words across line boundaries
    def replace_across_lines(match):
        return match.group(1) + match.group(2)

    # Regex for matching repeated words across line boundaries
    across_lines_pattern = re.
		compile(r'\b(' + '|'.join(
			map(re.escape, common_words)) +
			r')\b(\s*[*\/\n\s]*)\b\1\b')
    combined_text = across_lines_pattern.
		sub(replace_across_lines, combined_text)

    # Split the text back into lines
    filtered_text = combined_text.split('/*sep*/')

    return '\n'.join(filtered_text)

def process_file(file_path):
    with open(file_path, 'r', encoding='utf-8') as file:
        text = file.read()

    new_text = filter_repeated_words(text)

    with open(file_path, 'w', encoding='utf-8') as file:
        file.write(new_text)

def process_directory(directory_path):
    for root, dirs, files in os.walk(directory_path):
        dirs[:] = [d for d in dirs if not d.startswith('.')]
        for file in files:
            # Filter out hidden files
            if file.startswith('.'):
                continue
            file_extension = file.split('.')[-1]
            if
	file_extension in valid_extensions:  # 只处理指定后缀的文件
                file_path = os.path.join(root, file)
                print(f"Processed file: {file_path}")
                process_file(file_path)

directory_to_process = "/home/mi/works/github/zephyrproject/zephyr"
process_directory(directory_to_process)

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2024-06-25 06:05:35 -04:00
Jordan Yates 07870934e3 everywhere: replace double words
Treewide search and replace on a range of double word combinations:
    * `the the`
    * `to to`
    * `if if`
    * `that that`
    * `on on`
    * `is is`
    * `from from`

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-22 05:40:22 -04:00
Peter Mitsis 4123c531f3 tests: Add test for IPI cascades
Adds a test to show that enabling IPI cascades
(CONFIG_SCHED_IPI_CASCADE=y) can correct an invalid set
of high priority threads on an N CPU system.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2024-06-21 20:49:11 -04:00
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