Commit graph

2591 commits

Author SHA1 Message Date
Daniel Leung 6c7cc1f683 tests: kernel/mp: extend to more CPUs
This extends the multi-processor start tests to more than
2 CPUs.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-07-21 17:48:05 -04:00
Daniel Leung fd3a8ee209 tests: kernel/sys_mutex: sleep a bit for private_mutex to lock
With SMP, the private_mutex may not be locked fast enough by
thread_12 after the thread creation as it might take longer
for a thread to start running the entry function, resulting
in test failure when the main test thread goes into locking
it again. So give it a bit more delay after thread creation
so thread_12 has a chance to lock the private_mutex.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-07-21 17:47:25 -04:00
Daniel Leung c719b70136 tests: kernel/smp: mark torture test as skipped if factor is 0
If CONFIG_SMP_TEST_RUN_FACTOR is zero, the switch torture test
is effectively not doing anything as the k_sleep() below is not
going to sleep at all, and all created threads are being
terminated (almost) immediately after creation. So if run
factor is zero, mark the test as skipped.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-07-21 17:46:46 -04:00
Anas Nashif 3a24476fb7 tests: kernel: fix some test identifiers
Fixed few test identifiers and tags.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-07-19 18:07:49 -04:00
Nicolas Pitre 141299fb80 tests: timer_behavior: better cope with timer wrap-arounds
Commit a1d21ca69b ("tests: timer_behavior: don't fail the test with
timer wrap-arounds") simply ignored the total time validation whenever
any rollover was detected. Let's adjust the end timestamp according
to the number of rollovers instead.

Documentation for sys_clock_cycle_get_32() says it should count up
monotonically through the full 32 bit space, wrapping at 0xffffffff.
Therefore we just need to add 2^32 times the number of rollovers to
the end timestamp.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-07-18 21:36:57 +00:00
Flavio Ceolin 3b7e0b672e kernel: userspace: Dynamic thread stack object
Add support for dynamic thread stack objects. A new container
for this kernel object was added to avoid its alignment constraint
to all dynamic objects.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-07-17 16:56:01 -04:00
Flavio Ceolin d58c9a1ca4 tests: kernel: threads: stack: Enable USERSPACE
Test that automatic thread stack allocation works for
both user and kernel threads.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-07-17 16:56:01 -04:00
Jimmy Zheng 82c2f388ee tests: kernel: gen_isr_table.riscv_direct: exclude adp_xc7k_ae350
Exclude adp_xc7k_ae350 because Andes core doesn't support RISC-V vectored
mode from csr $mtvec.

Signed-off-by: Jimmy Zheng <jimmyzhe@andestech.com>
2023-07-17 10:10:31 +00:00
Christopher Friedt 1323b1ac60 tests: kernel: threads: add a testcase for dynamic thread stacks
Test that automatic thread stack allocation works for
both user and kernel threads.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-07-13 17:16:32 -04:00
Florian Grandel 38e2eb8fe6 soc: ti: cc13/26xx: clean up include hierarchy
Removes duplicate code and inconsistencies in the naming of the
cc13xx_cc26xx devicetree and RTC driver hierarchy and alignes it with
the actual TI product series naming hierarchy.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-07 18:46:24 -04:00
Jordan Yates c3c586a1b4 tests: kernel: events: test return value
Add tests for the return value of `k_event_post`, `k_event_clear`,
`k_event_set` and ``k_event_set_masked`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-07 09:24:25 +02:00
Christopher Friedt 28a8b151cf tests: kernel: spinlock: add test for k_spin_trylock()
Add a testcase to exercise two cases:
* when `k_spin_trylock()` fails (lock is busy)
* when `k_spin_trylock()` succeeds (lock is acquired)

We use the same machinery for checking for a recursive mutex
as `k_spin_lock()`.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-07-05 21:06:55 -04:00
Dmitrii Golovanov 85c5a25e09 tests: workq: Add timeout parameter
Add TEST_WORK_ITEM_WAIT_MS and TEST_SUBMIT_WAIT_MS config parameters
instead of hardcoded timeouts at kernel.workqueue test to allow its
customization on slow simulated platforms.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-06-26 16:14:02 +02:00
Daniel Leung 71b522cfdd tests: kernel/mp: move CONFIG_KERNEL_COHERENCE to Kconfig
This moves CONFIG_KERNEL_COHERENCE from prj.conf to Kconfig.
This gets rid of the cmake warning where CONFIG_KERNEL_COHERENCE
is assigned the value 'y' but gets the value ''. This is simply
done to avoid confusion when running the test manually.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-21 13:59:36 -04:00
Huifeng Zhang 9edd2951ef tests: kernel: fpu_sharing: Add double type support
Use double type when FPU supports double precision.

Signed-off-by: Huifeng Zhang <Huifeng.Zhang@arm.com>
2023-06-21 16:06:08 +02:00
Huifeng Zhang 1cec85dc07 tests: kernel: fpu_sharing: Enable it on VFP platfrom of aarch32
- Remove raising compilation error in `float_regs_arm_gcc.h`
    These macros are checked in 'load_store.c', so no need to check them
    again in 'float_regs_arm_gcc.h'

- Enable this test on the VFP platform of aarch32

Signed-off-by: Huifeng Zhang <Huifeng.Zhang@arm.com>
2023-06-21 16:06:08 +02: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
Anas Nashif b835b02136 tests: cleanup metadata and filtering
- Add integration_platforms to avoid excessive filtering
- Make sure integration platforms are actually part of the filter
- Fix some tags and test meta data

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-06-13 09:38:27 -04:00
Andrzej Głąbek 4d511cfb6a tests: timer_api: Decrease tick rate for nRF RTC timer
The default tick rate for the nRF RTC timer is 32768 Hz, so one tick
is ~30 us. This turns out to be too little for the following loop
executed in user mode on the Network core in nRF5340:
```
	do {
		t0 = k_uptime_ticks();
		rem_ticks = k_timer_remaining_ticks(&remain_timer);
		t1 = k_uptime_ticks();
	} while (t0 != t1);
```
The time between the two calls to `k_uptime_tick()` is there always
above 30 us, so the loop never ends.

This patch decreases the tick rate for all nRF platforms because on
other nRf SoCs the time mentioned above is also close to 30 us and
apparently changes in code completely unrelated to this test affect
execution time of system calls in the above loop - the test started
to fail after commit 0014dd05f0 that
changes fdtable was merged and if `fdtable.c` is for example just
temporarily excluded from the build, the test passes.

The root cause of the problem seems to be related to user space
handling and this should to be investigated further. This patch
is applied only to allow this test to pass for the time being.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-06-12 14:04:56 -04:00
Andrzej Głąbek a874fddadd tests: timer_behavior: Use bigger drift tolerance for nRF RTC timer
Use 13% instead of the default 10% when the nRF RTC timer is used
so that the allowed drift is at least one tick long (~122 us in
this case).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-06-12 14:04:42 -04:00
Carlo Caione edd3437826 riscv: Rename Kconfig symbol to *_PRIVILEGED
Rename SOC_FAMILY_RISCV_PRIVILEGE to SOC_FAMILY_RISCV_PRIVILEGED because
the spec is "privileged".

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-06-09 11:46:29 -04:00
Peter Mitsis d26d3f9fd4 test: Change loop calibration count initialization
The kernel/context test_timer_interrupts() test has a loop calibration
phase to estimate the number of loops needed for 1 system tick.
By initializing this calibration to 1 instead of 0, we can avoid an
edge condition where the calibration phase indicates 0 loops are
required (a case that could happen when running on a slow simulator).

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-06-02 17:43:59 -04:00
Anas Nashif fa98745a10 tests: remove linker_generator sub tests from kernel
Kernel is being built the same way for all those tests and there is not
much related to the linker generator in any of those tests. Just keep a
small set of tests to have needed coverage in the kernel.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-06-02 04:47:06 -04:00
Declan Snyder 670e2a28fb tests: userspace: Support mimxrtXXX_evk_cm33
RT685 and RT494 ran out of mpu regions to do this test,
so add board overlays to disable the USB SRAM MPU
region definition because it is not needed for this test.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-06-01 19:02:58 -04:00
Keith Packard 091948a5a9 tests: Increase a couple of test stack sizes
mem_protect and sprintf stacks both need to be slightly larger than
currently defined in order to avoid stack overflow when using picolibc.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-06-01 13:43:25 -04:00
Jaxson Han 7d174eed41 test: kernel: fpu_sharing: Fix text exception by increasing the stack size
The test case will show an unexpected exception in the idle thread after
all test cases pass. The issue is caused by the main thread
stackoverflow.

Increase the main stack configured in this test case to fix the issue.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2023-05-30 10:14:55 +02:00
Lukasz Mrugala 2d1ab025b0 tests: shared_multi_heap: Docstring typo fix
Word 'platform' misspelled as 'plaform'.

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
2023-05-29 14:34:33 -04:00
Krzysztof Chruscinski 5a7f80feb3 tests: kernel: usage: Relax timing requirements for RISCV
Test was previously relaxed for RISCV machine timer. I have a
platform where it fails on RISCV requiring further relaxation.
Relaxing precision for RISCV architecture.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2023-05-27 06:26:13 -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
Evgeniy Paltsev 658ed409c1 SMP: reproduce finalized test case
Test case for threads abort issue.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-05-27 06:17:22 -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
Daniel Leung c9b5326270 tests: kernel/userspace: add a test for kernel only thread
This adds a test to make sure kernel only threads cannot go
into user mode: doing so would result in kernel panic.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-05-25 16:30:26 -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
Anas Nashif 5d8c8f3838 tests: sys_sem: cleanup test metadata
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
Anas Nashif ea103f7a0b tests: sys_mutex: cleanup test metadata
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
Carlo Caione 6f3a13d974 barriers: Move __ISB() to the new API
Remove the arch-specific ARM-centric __ISB() macro and use the new
barrier API instead.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-05-24 13:13:57 -04:00
Carlo Caione cb11b2e84b barriers: Move __DSB() to the new API
Remove the arch-specific ARM-centric __DSB() macro and use the new
barrier API instead.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-05-24 13:13:57 -04:00
Anas Nashif c5d798173c tests: improve filtering and use integration_platforms
Use integration platforms to limit scope in CI.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-05-24 07:50:50 -04:00
Anas Nashif 689ea54b78 tests: do not filter on SMP, use board yaml file
Avoid expensive runtime filtering and use platform features instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-05-24 07:50:50 -04:00
Mahesh Mahadevan df26e99637 pm: rt5xx: Enable OS Timer as wakeup source
1. Enable os_timer as a wakeup-source in the board
   dts file.
2. Enable PM_DEVICE when PM is enabled.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2023-05-16 18:19:35 +02:00
TOKITA Hiroshi 8d28cb094b tests: kernel: add qemu_riscv to no-multithreading tests
Add qemu_riscv32, qemu_riscv32e, and qemu_riscv64 targets
to the tests that list below. These set CONFIG_MULTITHREADING=n.

- tests/kernel/fatal/no-multithreading
- tests/kernel/mem_heap/mheap_api_concept
- tests/kernel/mem_slab/mslab_api
- tests/kernel/threads/no-multithreading

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-05-12 09:56:40 +02: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
Keith Packard bfa6a44746 tests,samples: Fix picolibc malloc arena settings
With picolibc moving to using the common malloc implementation, samples and
tests with picolibc-specific settings need to switch to using the common
malloc settings instead.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-05-09 01:29:16 +09:00
Alberto Escolar Piedras b10817ba25 tests: timer cycle64: Fix filtering for POSIX arch
This test was excluding and including only
the native_posix board, while it should have instead
excluded/allowed anything in the architecture.
=> Change the filtering accordingly.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-05-04 16:48:01 -04:00
Mahesh Mahadevan b26eb63e88 tests: tickless_concept: Fix failures seen on NXP RT595
Add the os_timer as a wakeup source so we can exit
deep-sleep modes.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2023-05-02 16:56:48 +02:00
Carlo Caione 826d35b188 tests: cache: Add missing cases
Some test cases are missing. Add those back.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-04-20 14:56:09 -04:00
Gerard Marull-Paretas 4d06166623 device: allow NULL init function
Some devices do not need to perform any initialization, so allow the
init function to be NULL. In this case, the initialization code will
just mark the device as initialized, i.e. ready.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-19 10:00:25 +02:00
Nicolas Pitre a1d21ca69b tests: timer_behavior: don't fail the test with timer wrap-arounds
If the timer driver only implements sys_clock_cycle_get_32() (meaning
CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER=n) and the hardware clock is high
enough then the reported cycle count may wrap an uint32_t during the
test. This makes validating the total test duration pointless as it
cannot be measured. Just print a warning instead of failing the test
in that case.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-04-18 16:46:13 -04:00
Nicolas Pitre e982bf71c5 tests: timer_behavior: jitter test using timer start delay and period
Exercize both the timer start delay as wellas the timer period and
gather stats for each.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-04-18 16:46:13 -04:00
Keith Packard e17191b146 tests/fpu_sharing: Increase main stack size on riscv64
Looks like switching the main return value to int means that stack
frame persists and increases stack usage by a few bytes. Increase the
main stack size to avoid overflows.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-14 07:49:41 +09:00
Keith Packard 0b90fd5adf samples, tests, boards: Switch main return type from void to int
As both C and C++ standards require applications running under an OS to
return 'int', adapt that for Zephyr to align with those standard. This also
eliminates errors when building with clang when not using -ffreestanding,
and reduces the need for compiler flags to silence warnings for both clang
and gcc.

Most of these changes were automated using coccinelle with the following
script:

@@
@@
- void
+ int
main(...) {
	...
-	return;
+	return 0;
	...
}

Approximately 40 files had to be edited by hand as coccinelle was unable to
fix them.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-14 07:49:41 +09:00
Gerard Marull-Paretas a5fd0d184a init: remove the need for a dummy device pointer in SYS_INIT functions
The init infrastructure, found in `init.h`, is currently used by:

- `SYS_INIT`: to call functions before `main`
- `DEVICE_*`: to initialize devices

They are all sorted according to an initialization level + a priority.
`SYS_INIT` calls are really orthogonal to devices, however, the required
function signature requires a `const struct device *dev` as a first
argument. The only reason for that is because the same init machinery is
used by devices, so we have something like:

```c
struct init_entry {
	int (*init)(const struct device *dev);
	/* only set by DEVICE_*, otherwise NULL */
	const struct device *dev;
}
```

As a result, we end up with such weird/ugly pattern:

```c
static int my_init(const struct device *dev)
{
	/* always NULL! add ARG_UNUSED to avoid compiler warning */
	ARG_UNUSED(dev);
	...
}
```

This is really a result of poor internals isolation. This patch proposes
a to make init entries more flexible so that they can accept sytem
initialization calls like this:

```c
static int my_init(void)
{
	...
}
```

This is achieved using a union:

```c
union init_function {
	/* for SYS_INIT, used when init_entry.dev == NULL */
	int (*sys)(void);
	/* for DEVICE*, used when init_entry.dev != NULL */
	int (*dev)(const struct device *dev);
};

struct init_entry {
	/* stores init function (either for SYS_INIT or DEVICE*)
	union init_function init_fn;
	/* stores device pointer for DEVICE*, NULL for SYS_INIT. Allows
	 * to know which union entry to call.
	 */
	const struct device *dev;
}
```

This solution **does not increase ROM usage**, and allows to offer clean
public APIs for both SYS_INIT and DEVICE*. Note that however, init
machinery keeps a coupling with devices.

**NOTE**: This is a breaking change! All `SYS_INIT` functions will need
to be converted to the new signature. See the script offered in the
following commit.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

init: convert SYS_INIT functions to the new signature

Conversion scripted using scripts/utils/migrate_sys_init.py.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

manifest: update projects for SYS_INIT changes

Update modules with updated SYS_INIT calls:

- hal_ti
- lvgl
- sof
- TraceRecorderSource

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: devicetree: devices: adjust test

Adjust test according to the recently introduced SYS_INIT
infrastructure.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: kernel: threads: adjust SYS_INIT call

Adjust to the new signature: int (*init_fn)(void);

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 14:28:07 +00:00
Franciszek Zdobylak ffe94b512f drivers: update overlays for HiFive Unmatched
HiFive Unmatched is using size and address cells of length 2. It has to
use different overlays (with reg properties of correct length).

Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
2023-04-12 13:05:55 +02:00
Kumar Gala 99fee43f07 tests: interrupt: Fix armclang compiler warning
When building this test with the armclang compiler we get the following
warning:

tests/kernel/interrupt/src/dynamic_isr.c
tests/kernel/interrupt/src/dynamic_isr.c:23:32: error: 'used' attribute
ignored on a non-definition declaration [-Werror,-Wignored-attributes]

extern struct _isr_table_entry __sw_isr_table _sw_isr_table[];
                               ^
There is no need to add the __sw_isr_table on the extern, so remove it
to address the warning.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-11 09:35:42 +02:00
Lucas Tamborrino 9e4d1a817c tests: kernel: fpu_sharing: generic: add xtensa testing
Add xtensa arch to FPU test.

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2023-04-08 12:34:25 +02:00
Anas Nashif fcefc27823 tests: remove intel adsp cavs platforms from filters
Remove all filters related to dropped platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-06 18:51:56 +02:00
Rick Tsao 1a51f6d45d tests: mem_protect: Add support for configurable granularity of PMP
Redefine MEM_REGION_ALLOC to make memory domain align with granularity
of PMP.

Signed-off-by: Rick Tsao <rick592@andestech.com>
2023-04-06 11:50:43 +02:00
Keith Packard 95a5c60abf tests/kernel: Cast time difference to int32_t before abs call
Clang complains when an unsigned value is passed to abs, even though there
is an implicit cast to a signed type. Insert an explicit cast to make clang
happy.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-05 10:38:34 +02:00
Anas Nashif 9a183fa912 tests: sys_mutex: do not use TC_START for debugging
TC_START is used to evaluate output of tests and is used internally by
ztest when a test starts, no need to call this manually here.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-05 10:27:28 +02:00
Anas Nashif 9d31177112 tests: kernel: timer: remove extra TC_START
TC_START is used to evaluate output of tests and is used internally by
ztest when a test starts, no need to call this manually here.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-05 10:27:28 +02:00
Anas Nashif 3f11cf497a tests: kernel: fatal: report testcase results
Report results, do not rely on the test success report at the end.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-05 10:27:28 +02:00
Anas Nashif a4e8cc25b2 tests: gen_isr_table: remove exta TC_START call
TC_START is used to evaluate output of tests and is used internally by
ztest when a test starts, no need to call this manually here.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-05 10:27:28 +02:00
Tomasz Moń c55266a925 tests: kernel: timer_behavior: Decrease tick rate for nRF
Nordic targets use 24-bit RTC peripheral for system clock. Nordic system
clock timeout implementation relies on RTC CC (capture compare) when
the timeout is in future. Nordic system clock driver allows setting
alarm only to 3 or more counts from current counter value due to silicon
limitation (to ensure that CC event triggers before counter overflow).

RTC CC limitation does not have much impact on normal applications where
there is no need to schedule such short timeouts, but is problematic in
a timer test that expects being able to repeatedly schedule timeouts on
subsequent ticks.

Reduce system tick rate to 8192 on nRF targets to allow setting CC to
the very next tick. With system tick rate being 4 times less than the
hardware tick rate, it is always possible to schedule timeout to happen
in the next tick because ticks are 4 counts apart, i.e. current timer
value + 3 never runs past the next tick.

Fixes: #54211

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-04-05 08:30:15 +02:00
Filip Kokosinski 491f27455e tests: mark testcases with pm where CONFIG_PM=y is forced
This commit marks testcases that require working Power Managament with
the appropriate `pm` tag to allow proper testcase filtering in the board
YAML file.

Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
2023-04-04 13:34:45 +02:00
Shawn Nematbakhsh bf46f73510 tests: Remove references to deleted board "beaglev_starlight_jh7100".
beaglev_starlight_jh7100 board was deleted so remove references to it in
tests/.

fixes: #56398

Signed-off-by: Shawn Nematbakhsh <shawn@rivosinc.com>
2023-03-31 07:13:24 -04:00
Ederson de Souza 52db964840 tests/kernel/smp: Limit 'stress' tests based on factor
SMP tests `inc_concurrency` and `smp_switch_torture` use a 'stressing'
approach to verify their results: run something for some time (or some
number of repetitions). However, in some environments, current 'stress'
levels can be quite high, making tests take a long time - environments
like emulators/simulators.
This patch adds a Kconfig that allows one to define a percentage factor
to the 'stress' (time or repetitions) used by these tests.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2023-03-30 09:44:00 -04:00
Daniel Leung e35733d2ff tests: mem_protect/syscalls: print FAILED when faulting
If there are any CPU exceptions, printing a failed message
would allow twister to stop early instead of waiting for
timeout.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-27 20:13:22 -04:00
Daniel Leung 4a39c0c49f tests: mem_protect/sys_sem: print FAILED when faulting
If there are any CPU exceptions, printing a failed message
would allow twister to stop early instead of waiting for
timeout.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-27 20:13:22 -04:00
Daniel Leung 97fe4833d8 tests: mem_protect: remove code to recover spinlock
The variable need_recover_spinlock is always set to false so
the spinlock recovery code is effectively no-op. So remove
everything related to the variable.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-03-24 09:04:13 +01: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
Nicolas Pitre 4cc21e2f4a tests: timer_behavior: accuracy improvements
Don't sample the first entry outside the timer as this is a different
code path which produces a different offset from the clock tick.

Use sys_clock_hw_cycles_per_sec() to be compatible with systems that
read their hardware clock frequency at run time.

Perform cycle difference computations with uint64_t. If ever the
magnitude of the absolute clock cycle values is greater than 52 bits
then the cast to a double will actually lose accuracy.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-03-02 21:14:52 +01:00
Jamie McCrae af78cbdc99 samples and tests: Add REQUIRED to Zephyr find_package call
Adds REQUIRED to samples and tests for finding the zephyr package
to align all samples and tests with the same call and parameters.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-02 09:58:27 +01:00
Nicolas Pitre b2e204e9a6 tests: timer_behavior: fix a period drift logic error
An assertion statement was a bit too strict. Period drift may come about
not only from kernel ticks being large but also from time conversion being
inexact due to division truncation.

Fixes: #55136

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-02-24 08:29:28 -05:00
Daniel Leung 116998c677 tests: kernel: print FAILED when wrong faults caught
For some kernel tests, faults and exceptions are expected.
They are caught and the test would continue if the reasons
for faults are as expected. However, when the unexpected
reasons are encountered, the code simply prints a message
and calls k_fatal_halt(). When running under twister,
these messages are not the expected failed messages so
twister will spin till timeout although the execution
has already been halted. This adds another printk() before
halt to signal twister that the test has failed and bails
early.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-02-21 18:06:44 -05:00
Daniel Leung d650d76d62 tests: mem_protect/mem_protect: join thread at end of test...
...test_inherit_resource_pool. This waits for the newly created
threads to finish before moving on to the next test. This fixes
an issue on qemu_x86_tiny where there would be a double fault
after all tests have run.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-02-21 18:06:44 -05:00
Kumar Gala 1c8f1cd590 tests: kernel: interrupt: workaround qemu_x86 interrupt issue
qemu_x86 seems to take an extra instruction after the sti instruction
(irq_unlock) happens before it posts the interrupts.  This can issues
if the instruction after the sti ends up reading the state that is
suppose to be updated by the ISR handler.

We see this behavior when building with LLVM.  To workaround this issue
we add an arch_nop() to provide an extra instruction to allow the
interrupts to post.

Opened zephyrproject-rtos/sdk-ng#629 to track qemu issue.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-02-21 16:17:20 -05:00
Kumar Gala d31814e990 tests: Fix floating point test variants on x86 w/LLVM
LLVM doesn't support SSE + 387 math.  As such if SSE is enabled we
have to utilize SSE floating point.  To utilize 387 math, SSE has
to be disabled.

Update the floating point related tests to introduce 387 only variants
that will build on both GCC & LLVM based tools.  Than we exclude llvm
based (llvm, oneApi) toolchains from the CONFIG_X86_SSE_FP_MATH=n and
CONFIG_X86_SSE=y test variants.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-02-21 08:25:38 -05:00
Nicolas Pitre 3c440af975 riscv: pmp: provision for implementations with partial PMP support
Looks like some implementors decided not to implement the full set of
PMP range matching modes. Let's rearrange the code so that any of those
modes can be disabled.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-02-20 10:57:11 +01:00
Nicolas Pitre 45623585ab tests/kernel/fpu_sharing/generic: enforce execution on a single CPU
This test relies on one thread interrupting another to exercize the FPU
sharing. On SMP those threads get one CPU each with no sharing of their
FPU making the test rather pointless.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-02-19 21:00:32 -05:00
Martí Bolívar 20c5866cb1 boards: mps2_an521: clean up memory map
Fix comments in board DTS files referring to AN521 tables defining
memory areas, and choose node label names that more accurately reflect
the entries of interest in those tables.

Adjust the one in-tree user of the affected node labels.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-02-19 20:55:47 -05:00
Kumar Gala 5605da129b tests: kernel: mem_protect: stackprot: Dont inline check_input
When building with LLVM on qemu_x86 we see the compiler ends up
inlining the check_input function.  This breaks the stack overflow
that the test is trying to generate, so mark the check_input()
function as noinline to fix the issue.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-02-19 20:47:44 -05:00
Nicolas Pitre a115fd21d4 tests: kernel: timer_behavior: improve the timer_jitter_drift output
Provide an estimate of the test duration.
Make the output nicer than a few overloaded and wrapped lines.
Provide more context in the presence of period time drift.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-02-19 20:34:37 -05:00
Nicolas Pitre b60cb9cc80 tests: kernel: timer_behavior: improve timer_tick_train output
Print the "perfect" reference period for easier evaluation.
Suggest a remedy to the missed ticks problem.

Still, that wasn't satisfactory. Implemented a count of missed ticks
to get to the bottom of this issue. Found that missed ticks always came
to a perfect count of 40.

Incidentally, the busy loop prints a line every 250 ms and the test spans
10 seconds. There are no such coincidences.

Turns out that CONFIG_PRINTK_SYNC was set by default. This disables IRQs
for the serial output duration, which can be quite long at 115200 bauds.
Given a 60-ish character line length, this represents more than 5 ms of
no IRQ servicing during a timer latency measurement test which is bad.
So make sure CONFIG_PRINTK_SYNC=n for proper statistics.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-02-19 20:34:37 -05:00
Evgeniy Paltsev e0de642d0a ARC: qemu: disable test where we trigger ARC QEMU bug #54720
Disable tests/kernel/mem_protect/syscalls for qemu_arc_em where
we trigger ARC QEMU bug which cause illegal instruction exception
on perfectly valid ARC code.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-02-17 08:50:37 +09:00
Aastha Grover 2196efe192 tests: kernel: cpu_exception: Make expected reason code generic.
Change expected reason code for cpu exception to be generic and
in compliance with a3774fd51a

Fixes #54335

Signed-off-by: Aastha Grover <aastha.grover@intel.com>
2023-02-02 18:35:01 -05:00
Peter Mitsis 7eb27d580b tests: kernel: Add events to object tracking
Adds a test for kernel event object tracking.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-02-02 20:21:12 +09:00
Keith Packard fb193e2d3d tests/mem_protect: Use minimal libc for kernel.memory_protection
This test has trouble on qemu_x86_tiny and randomly generates a Double
Fault error. I couldn't get it to reliably run with picolibc as a Double
Fault usually occured before the test completed.

I spent a couple of hours attempting to track this down and found that it
happens when code pages for the main thread get unmapped because the
qemu_x86_tiny intentionally offers very few available PTEs.

Work around this by just using the minimal libc for this test.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-01-30 23:46:55 +00:00
Keith Packard 6738e8e9df tests/x86/mem_protect: Disable picolibc heap for demand paging tests
These tests don't need any libc heap and currently fail when one is
available.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-01-30 23:46:55 +00:00
Jordan Yates 839ca44f80 Revert "tests: update expected exception codes"
This reverts commit d8ac658578.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-01-27 18:09:32 +09:00
Keith Packard e490fe0f67 tests: kernel: Provide more stack space for context test
This test overflows when TLS is used, provide plenty of extra space to
avoid that.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-01-26 10:04:33 +00:00
Jan Malek 6fb644c663 renode: Add Renode overlays for selected tests
Tune quantum parameter for selected kernel tests
targetting the HiFive Unleashed platform.

Those tests require higher fidelity of the virtual
time flow which is achievable on multi-core platforms
in Renode by reducing the quantum.

Signed-off-by: Jan Malek <jmalek@internships.antmicro.com>
Signed-off-by: Mateusz Holenko <mholenko@antmicro.com>
2023-01-25 14:02:29 -08:00
Nicolas Pitre 189fcbb3af tests: float_disable: this is no longer applicable to RISC-V
With lazy FPU context switching, k_float_disable() is merely triggering
a synchronous FPU context save and k_float_enable() is a no-op.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-01-24 15:26:18 +01:00
Evgeniy Paltsev 122c7be703 tests: smp: fix fatal on smp test case
After the dbe3874079 - (tests: kernel/smp: wait for threads to exits
between tests) I've started seeing sporadic kernel.multiprocessing.smp
test failures on our platforms.

------------------------------->8---------------------------------
[*snip*]
===================================================================
START - test_fatal_on_smp
E:  r0: 0x3  r1: 0x0  r2: 0x0  r3: 0x0
E:  r4: 0x80000194  r5: 0x0  r6: 0x0  r7: 0x0
E:  r8: 0x800079c4  r9: 0x82802 r10: 0x80008d8c r11: 0x8000dad8
E:  r0: 0x3  r1: 0x2712  r2: 0x114  r3: 0x0
E:  r4: 0xf4240000  r5: 0x0  r6: 0xf424  r7: 0xbe40
E:  r8: 0x2540  r9: 0x0 r10: 0x80008d8c r11: 0x8000db8c
E: r12: 0x8000ddf0 r13: 0x0  pc: 0x80000aec
E:  blink: 0x80000ae6 status32: 0x80082002
E: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 0
E: Current thread: 0x8000db8c (test_fatal_on_smp)
E: r12: 0x8000ddf0 r13: 0x0  pc: 0x8000019a
 PASS - test_fatal_on_smp in 0.014 seconds
===================================================================
START - test_get_cpu
E:  blink: 0x80001490 status32: 0x80082002
E: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 1
E: Current thread: 0x8000dad8 (unknown)
------------------------------->8---------------------------------

The rootcause if that we doesn't proper cleanup resources after
test_fatal_on_smp test case. So child thread we start test_fatal_on_smp
may continue running for some time after the test_fatal_on_smp
test case is finished.

As in the next test case (test_get_cpu) we use same thead structures
again to create new child thread we may actually rewrite some data of
thread which is still running (or vise versa).

As we trigger the crash in test_fatal_on_smp we can't simply join
child thread in the end of test case (as we never get here). We can't
simply use join child thread before we initiate crash in test_fatal_on_smp
either as we don't want to introduce reschedule point here which may break
the test logic.

So, to fix that, we'll just do k_busy_wait in test_fatal_on_smp
thread after we start child thread to wait for thread trigger
exception and being terminated.

To verify that we also assert that child thread is dead by the
time when we stop busy waiting.

Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2023-01-17 21:51:26 +00:00
Anas Nashif ed79b1f25e tests: use namespacing in extra_configs and drop duplicated scenarios
Use namespacing with extra_configs in some tests and remove duplicated
scenarios the were made arch or platform specifc.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-13 09:42:59 +01:00
Kevin Townsend ec3dc8c50a tests: kernel: fatal: Catch EPSR reason code
Adds a check for `K_ERR_ARM_USAGE_ILLEGAL_EPSR` as the reason code
when running this test for `CONFIG_ARMV7_M_ARMV8_M_MAINLINE`.

Signed-off-by: Kevin Townsend <kevin.townsend@linaro.org>
2023-01-13 12:18:05 +09:00
Jordan Yates d8ac658578 tests: update expected exception codes
Update expected exception codes for Cortex-M, Cortex-R and Cortex-A
CPUs.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-01-12 10:01:05 +01:00
Flavio Ceolin e31f4de09e tests: obj_validation: Call setup function
The setup function for object validation test was defined
but no called.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-01-10 19:23:57 -05:00
Fabio Baltieri f5b4acac57 yamllint: indentation: fix files in tests/
Fix the YAML files indentation for files in tests/.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 14:23:53 +01:00
Fabio Baltieri 7db1d17ee3 yamllint: fix all yamllint line-length errors
Fix all line-length errors detected by yamllint:

yamllint -f parsable -c .yamllint $( find -regex '.*\.y[a]*ml' ) | \
  grep '(line-length)'

Using a limit is set to 100 columns, not touching the commandlines in
GitHub workflows (at least for now).

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 01:16:45 +09:00
Fabio Baltieri 7dd902d035 yamllint: fix all yamllint comments-indentation errors
Fix all comments-indentation errors detected by yamllint:

yamllint -f parsable -c .yamllint $( find -regex '.*\.y[a]*ml' ) | \
  grep '(comments-indentation)'

This checks that the comment is aligned with the content.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 01:16:45 +09:00
Fabio Baltieri 5c32300861 yamllint: fix all yamllint truthy errors
Fix all thruthy errors detected by yamllint:

yamllint -f parsable -c .yamllint $( find -regex '.*\.y[a]*ml' ) | \
  grep '(truthy)'

This only accepts true/false for boolean properties. Seems like python
takes all sort of formats:

https://github.com/yaml/pyyaml/blob/master/lib/yaml/constructor.py#L224-L235

But the current specs only mention "true" or "false"

https://yaml.org/spec/1.2.2/#10212-boolean

Which is the standard yamllint config.

Excluding codeconv and workflow files, as some are using yes/no instead
in the respective documentation.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 01:16:45 +09:00
Hein Wessels 3210541c86 toolchain: gcc: rename popcount to avoid conflict with C++20
The macro conflicts with the C++20 feature std::popcount

fixes zephyrproject-rtos/zephyr#53421

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2023-01-03 11:06:45 +01:00
Lucas Tamborrino a5515d43a5 tests: kernel: fpu_sharing: add xtensa arch
Add xtensa arch to Shared Floating Point Support test.

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2022-12-27 13:23:17 +01:00
Piotr Kosycarz b8815ddc36 tests: kernel: timer: starve: Adjust timeout value
The test in its default configuration needs 3600 seconds to complete,
adjust timeout for twister to meet that.

Signed-off-by: Piotr Kosycarz <piotr.kosycarz@nordicsemi.no>
2022-12-21 10:11:23 +01:00
Tom Burdick 392a753ac2 tests: spin lock timeout test spin time
The spin loop to ensure time goes past the timeout is done in terms
of the core clock, while the spin lock is timed on the system clock.

This difference is exasperated on systems where the core clock is much
faster than the system clock and the test failed. Add a significant
multiplier so the test works even when the system clock is much slower.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-12-14 13:44:36 -06:00
Evgeniy Paltsev 7b4fc1d6d2 tests: re-enable tests which were disabled due to ARC QEMU issues
Re-enable several mem_protect tests which were disabled due to
issues in ARC QEMU (which are fixed and fixes were propagated to
Zephyr SDK)

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-12-08 16:59:15 +09:00
Andrzej Głąbek d908afd820 tests: kernel: fifo_timeout: Do not print status messages during tests
... to avoid undesirable delays in waking up of the threads on
scheduled timeouts. In specific configurations such additional load
of the CPU can be even harmful to the test. This was observed for
nRF platforms where the UART_NRF_DK_SERIAL_WORKAROUND Kconfig option
was enabled.
All calls to TC_PRINT() in this test suite are replaced with calls to
LOG_DBG(), so the status messages are not printed by default, but they
can be enabled if needed by changing CONFIG_LOG_DEFAULT_LEVEL.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-12-05 13:38:16 +01:00
Andrzej Głąbek 39dd48cb6f tests: kernel: fifo_timeout: Correct misleading error message
In the message reporting the wrong order of woken up threads
(e.g. "thread 3 woke up, expected 2"), provide indexes of
the threads in the timeout order array, not their timeout
order values.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-12-05 13:38:16 +01:00
Carlo Caione b504d388ea tests: cache: Add cache test
This is useful to prove that the implementation of the API is done
correctly.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-12-01 13:40:56 -05:00
Anas Nashif e5d940f688 tests: kernel: do not set excluded as integration platform
excluded platforms shall not be set as integration platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-30 16:00:42 -05:00
Anas Nashif ba7d730e9b tests/samples: use integration_plaforms in more tests/samples
integration_platforms help us control what get built/executed in CI and
for each PR submitted. They do not filter out platforms, instead they
just minimize the amount of builds/testing for a particular
tests/sample.
Tests still run on all supported platforms when not in integration mode.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-29 16:03:23 +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 808266a493 tests: use ignore_fault field instead of tags
Use dedicated field in the yaml file instead of mixing this testing
feature with tags.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-25 06:38:05 -05: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
Daniel Leung 75fd531164 tests: mem_map: test if z_phys_unmap reclaim memory correctly
This adds a test to see if z_phys_unmap() can reclaim memory
correctly, so that the next z_phys_map() re-uses the same
address (with identical input arguments).

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-11-17 15:56:04 +00:00
Andrzej Głąbek 943b2d1924 tests: kernel: timer_behavior: Relax a bit the timer_tick_train test
The requirement of being able to spend only 10% of processing time
on execution of timer handlers that are scheduled on every tick is
not really possible to fulfill on platforms like the nRF ones where
the tick period is quite short (~30 us in this case). Relax this
requirement and accept if at least one-third of the processing time
is available for other work while handling the timer tick train.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-11-16 11:20:55 +01:00
Andrzej Głąbek 96f1ee93fc tests: kernel: timer: starve: Add proper timeout value
The test in its default configuration needs 3600 seconds to complete,
so use such timeout value in testcase.yaml so that twister called with
--enable-slow option can successfully execute it.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-11-11 13:03:17 +01:00
Krzysztof Chruscinski ff13057008 tests: kernel: workq: work: Tweak test for fast system clock
Test assumes that system clock is slow enough so 1 tick timeout
will not expire before k_timer_start function exists. That is
not the case when system clock is fast (relatively to the cpu
clock). Increase the timeout and add synchronization point.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-11-09 10:44:52 +01:00
Enjia Mai 0d5555e728 tests: kernel: mem_protect: fix incorrect skip on mem_map test
The mem_map test was skipped on all the phsical x86 boards when
running twister to test them. This error happens when migrating
the new ztest. Remove the incorrect platform allow to fix this
error.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-11-09 09:25:08 +00:00
Keith Packard 82352fda28 tests/mem_protect/userspace: Disable picolibc malloc heap
Reduces MPU partition usage when building with picolibc

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-11-08 10:44:36 +01:00
Keith Packard 71bf8623e3 tests/mem_map: Disable picolibc malloc heap
Reduces MPU partition usage when building with picolibc

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-11-08 10:44:36 +01: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
Keith Packard 62b0ef376b tests/kernel: Delay between thread creation in stack random test
This avoids problems when using timers for random numbers; run too fast and
all the values are the same.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-11-08 10:44:36 +01:00
Daniel Leung 65f6e3a4e3 tests: mem_map: compare just written data too in mapped_rw
After writing to mapped_rw, we should also check if the backing
buffer has the correct data. Or we could have a situation where
on systems that need explicit cache controls, the newly updated
mapped_rw is cached but the backing buffer still contain old
data. Comparing the backing buffer to mapped_ro does not really
matter in this case as the content would certain match.

Also, this moves the mapping of mapped_ro earlier so that we
map both mapped_rw and mapped_ro because data manipulation.

And that we also need to verify the values of the backing and
mapped buffers.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-11-05 19:56:57 +01:00
Daniel Leung 97b89b659b tests: mem_map: fix potential out-of-bound for test buffer
There is an assumption on test_page buffer that the MMU page
size is 4kb so that there is a 8kb buffer for read/write.
However, page size may not be 4kb on all architectures.
We need to make sure the test buffer is large enough for
the read/write test.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-11-05 19:56:57 +01:00
Anas Nashif 064626386c tests: kernel: schedule_api: fix filter
Readd filter that was removed by mistake in a commit fixing meta-data.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-05 13:44:14 -04:00
Daniel Leung 4f2b7c693e tests: sys_sem: no k_thread_access_grant call if not userspace
The sys_sem.nouser test does not enable userspace which makes
k_thread_access_grant() no-op. However, XCC would still emit
LOOP instructions for the for-loop. Since there is nothing
to do, the XCC assembler complains about it being an empty
loop and errors out. So guard the k_thread_access_grant()
calls so they are only compiled if userspace is enabled.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-11-05 08:29:01 -04:00
Anas Nashif e21cc69c90 tests: kernel: cleanup test meta-data
Mostly tag cleanup and fixing issues related to bad filtering in the
link_generator scenarios.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-04 22:13:54 -04:00
Anas Nashif a4d1c91115 tests: gen_isr_table: remove duplicate platform_allow
We should not have duplicated keys.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-04 22:13:54 -04:00
Anas Nashif 1b561d0f30 tests: kernel: fatal: cleanup test configuration
Use common section and remove duplication.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-04 22:13:54 -04:00
Chris Friedt 4f57b42571 tests: kernel: mutex: move race timeout test to mutex_api
Previously, this change was added to `mutex_error_case`.

That worked fine in `main`, but once the change was backported to
`v2.7-branch`, the test would fail because it *did not* cause a
failure. The reason for that, was that the `mutex_error_case`
suite has `CONFIG_ZTEST_FATAL_HOOK=y`.

With the newer ztest API, it allowed a separate suite to be used,
allowing the test to pass (although it did not really fit in with
the rest of the testsuite).

The solution is to simply merge it with the `mutex_api` suite
which uses non-inverted success logic.

This change will also have to be cherry-picked for the backport
in #49031.

Fixes #48056.

tests: kernel: mutex: move race timeout test to mutex_api

Previously, this change was added to `mutex_error_case`.

That worked fine in `main`, but once the change was backported to
`v2.7-branch`, the test would fail because it *did not* cause a
failure. The reason for that, was that the `mutex_error_case`
suite has `CONFIG_ZTEST_FATAL_HOOK=y`.

With the newer ztest API, it allowed a separate suite to be used,
allowing the test to pass (although it did not really fit in with
the rest of the testsuite).

The solution is to simply merge it with the `mutex_api` suite
which uses non-inverted success logic.

This change will also have to be cherry-picked for the backport
in #49031.

Fixes #48056.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-10-31 21:23:29 -04:00
Chris Friedt 024e9496d0 Revert "tests: kernel: mutex: test for lock timeout race"
This reverts commit 019a6ecae3.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2022-10-31 21:23:29 -04:00
Kumar Gala 1a5495adea tests: kernel: smp_boot_delay: Convert CONFIG_MP_NUM_CPUS handling
Move build and build system checks to use CONFIG_MP_MAX_NUM_CPUS
as we phase out CONFIG_MP_NUM_CPUS.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-31 17:09:06 +01:00
Kumar Gala f7522cb71e tests: kernel: spinlock: Convert CONFIG_MP_NUM_CPUS handling
Move build and build system checks to use CONFIG_MP_MAX_NUM_CPUS
as we phase out CONFIG_MP_NUM_CPUS.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-31 17:09:06 +01:00
Kumar Gala b0e916ba67 tests: kernel: smp: Convert CONFIG_MP_NUM_CPUS handling
Move runtime checks to use arch_num_cpus() and build checks
to use CONFIG_MP_MAX_NUM_CPUS.  This is to allow runtime
determination of the number of CPUs in the future.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-31 17:09:06 +01:00
Kumar Gala 0a8cef84ae tests: kernel: mp: Convert CONFIG_MP_NUM_CPUS handling
Move build and build system checks to use CONFIG_MP_MAX_NUM_CPUS
as we phase out CONFIG_MP_NUM_CPUS.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-31 17:09:06 +01:00
Kumar Gala 311a46e948 tests: mem_slab: mslab_api: Convert CONFIG_MP_NUM_CPUS handling
Move runtime checks to use arch_num_cpus() to use
CONFIG_MP_MAX_NUM_CPUS.  This is to allow runtime
determination of the number of CPUs in the future.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-31 17:09:06 +01:00
Kumar Gala b5ec4109d3 tests: mem_protect: syscalls: Convert CONFIG_MP_NUM_CPUS handling
Move runtime checks to use arch_num_cpus() and build checks
to use CONFIG_MP_MAX_NUM_CPUS.  This is to allow runtime
determination of the number of CPUs in the future.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-31 17:09:06 +01:00
Kumar Gala ec8a689fcc tests: kernel: smp: pick a platform that makes sense for the tests
Pick a platform that actual supports SMP - qemu_x86_64.  Remove setting
CONFIG_TIMESLICING as that is already set.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-31 09:08:35 -05:00
Kumar Gala c03ef06fff tests: kernel: mp: pick a platform that makes sense for the tests
Pick a platform that actual supports MP - qemu_x86_64.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-31 09:08:35 -05: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
Tom Burdick 6cef9ca595 tests: Fix coherence of timeout spin lock
Spin locks must be in coherent memory for cavs. Initially this variable
was at the compilation unit scope but warnings about it being unused
from a twister run lead me to move it to be in the ifdef scope in the
function.

Move it back into the compilation units scope and wrap it in an
ifdef to ensure its not labeled as unused.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-10-26 15:33:43 -07:00
Tom Burdick 1644cc69d7 tests: Fix spinlock time limit test
Set the time limit to be long enough not to trigger too early. Do
not unlock after assert when doing the time limit test.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-10-22 14:37:03 +09:00
Kumar Gala a1195ae39b smp: Move for loops to use arch_num_cpus instead of CONFIG_MP_NUM_CPUS
Change for loops of the form:

for (i = 0; i < CONFIG_MP_NUM_CPUS; i++)
   ...

to

unsigned int num_cpus = arch_num_cpus();
for (i = 0; i < num_cpus; i++)
   ...

We do the call outside of the for loop so that it only happens once,
rather than on every iteration.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-21 13:14:58 +02:00
Kumar Gala fc95ec98dd smp: Convert #if to use CONFIG_MP_MAX_NUM_CPUS
Convert CONFIG_MP_NUM_CPUS to CONFIG_MP_MAX_NUM_CPUS as we work on
phasing out CONFIG_MP_NUM_CPUS.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-20 22:04:10 +09:00
Kumar Gala 4f0166088c tests: move to using CONFIG_MP_MAX_NUM_CPUS
For tests that set CONFIG_MP_NUM_CPUS, switch to using
CONFIG_MP_MAX_NUM_CPUS instead as we work to phase out
CONFIG_MP_NUM_CPUS.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-20 22:04:10 +09:00
Tom Burdick 872e3553f9 kernel: Option to assert on spin lock time
Spin locks held for any lengthy duration prevent interrupts and
in a real time system where interrupts drive tasks this can be
problematic. Add an option to assert if a spin lock is held for
a duration longer than the configurable number of microseconds.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-10-18 14:14:12 +02:00
Gerard Marull-Paretas 178bdc4afc include: add missing zephyr/irq.h include
Change automated searching for files using "IRQ_CONNECT()" API not
including <zephyr/irq.h>.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 22:57:39 +09:00
Andy Ross 6a1f721dda tests/kernel/workq: Fix semaphore counting
This test case will call k_sem_give() twice and expect both to be
received by k_sem_take(), yet the semaphore is initialized with a
maximum count of one!

The reason this worked was an undocumented misfeature of k_sem: if
k_sem_take() was called on a semaphore with a pended thread, it would
wake up that thread synchronously instead of incrementing the count.
So you could call it once to wake up the thread and again to queue the
count and not overflow.  The problem is that this is a priority bug (a
high priority runnable thread should have the chance to run and call
k_sem_take() before a low priority thread that got woken).

Zync corrects that, and so needs to have two slots if you want two
semaphore events.

Signed-off-by: Andy Ross <andyross@google.com>
2022-10-17 10:13:56 +02:00
Tom Burdick 2666702cd1 tests: Tick rate testing with timer train
Test timers with a train of one tick timers to test that
a configured SYS_CLOCK_TICKS_PER_SEC is sensible. If the TICKS_PER_SEC
is too high the timer train will take longer than expected to reach
the station. Worse, if the timer driver has too short of a minimum
delay for its processing power and the tick rate is too high its
possible the device will get caught in an interrupt loop
preventing any threads from running while processing timers.

This test validates that the tick rate configured is actually able to be
processed without delays while also having work done in threads ensuring
that no thread scheduling delays occur either from delayed timers or an
interrupt loop from preventing threads from running.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-10-12 20:42:22 -04:00
Tom Burdick 00abfa975b tests: Timer behavior custom test_main
Adds a custom test_main and renames the test suite for jitter_drift.

Runs the jitter_drift test suite.

The order of these tests matter on hardware as the counter is often
reset on loading the test program. This is useful as its far less likely
to encounter a clock counter rollover. On arm this is especially useful.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-10-12 20:42:22 -04:00
Tom Burdick bcc1165367 tests: Rename timer behavior main.c
Move the main.c timer behavior test code to jitter_drift.c
so that other tests may be added to the suite.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-10-12 20:42:22 -04:00
Gerard Marull-Paretas 495245a971 init: remove _SYS_INIT_LEVEL* definitions
The _SYS_INIT_LEVEL* definitions were used to indicate the index entry
into the levels array defined in init.c (z_sys_init_run_level). init.c
uses this information internally, so there is no point in exposing this
in a public header. It has been replaced with an enum inside init.c. The
device shell was re-using the same defines to index its own array. This
is a fragile design, the shell needs to be responsible of its own data
indexing. A similar situation happened with some unit tests.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-12 18:49:12 +09:00
Enjia Mai d37bd2eb3f tests: timer: timer_behavior: add a tick align
Add a tick align to reduce errors of calculating the
spending cycles.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-10-12 18:47:19 +09:00
Anas Nashif e8395351e6 kernel: init: introduce a new init level: ARCH
We have cases where some devices needs to be initialized very early and
before c_start is call, i.e. to setup very early console or to setup
memory. Traditionally this would be hardcoded as part of the soc layer
and not using device model or the init levels.

This patch adds a new level ARCH, which will be called in early
architecture code and before we jump to the kernel code.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-11 08:28:25 -04:00
Evgeniy Paltsev a76103ce59 tests/kernel/context: don't do print in time-critical section
In test_busy_wait and test_k_sleep test cases of
tests/kernel/context test we measure not only execution time of the
primitives itself (k_busy_wait and k_msleep respectively) but also
the overall test thread execution time.

The issue here is that we do printing in test threads which
means that we do printing in time-critical sections. That breaks
test if we do printing via some device which isn't fast enough.

Fix that by removing print from time-critical section

Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2022-10-11 11:11:45 +02: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
Christopher Friedt 019a6ecae3 tests: kernel: mutex: test for lock timeout race
Say threadA holds a mutex and threadB tries
to lock it with a timeout, a race would occur
if threadA unlock that mutex after threadB
got unpended by sys_clock and before it gets
scheduled and calls k_spin_lock.

This patch supplies the test that can be used
to reproduce the problem and the fix that was
provided in #48056

Fixes #48056

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
2022-09-30 09:45:37 +00:00
Andrzej Głąbek a30a65215d tests: kernel: timer_behavior: Fix building on targets with small SRAM
In the default configuration of the test, with 10000 timer samples,
the `periodic_data` array is too big to fit in SRAM on many targets.
Use lower counts of samples for those, depending on their SRAM size,
leaving at least 8 kB for other variables, buffers, stacks etc.
Exclude the test for targets with less than 16 kB.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-09-29 13:36:00 -05:00
Nicolas Pitre 91e8a17be4 tests/semaphore: fix "cpu test took too long" assertion failure
The SMP config for RISC-V on QEMU triggers this:

|START - test_sem_queue_mutual_exclusion
|
|Assertion failed at
| WEST_TOPDIR/zephyr/subsys/testsuite/ztest/src/ztest_new.c:155:
| cpu_hold: (dt < 3000 is false)
|1cpu test took too long (4090 ms)
|ERROR: cannot fail in test 'after()', bailing

Looping 10000 times is maybe a bit excessive.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-09-28 07:53:56 +00:00
Anas Nashif 489e8eb02c tests: timer_behavior: nsim_em is now marked as simulator
remove nsim_em from exclude list, it is now being excluded as a
simulator.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-09-26 16:49:58 +00:00
Stephanos Ioannidis 384ff96b25 Revert "tests: kernel: interrupt: Disable on ARM64 QEMU targets"
This reverts the commit 7d8a119213
because GCC is now configured to not emit ldp/stp Qn instructions for
consecutive 32-byte loads and stores, and the nested interrupt handling
failure due to the missing emulation of these instructions no longer
occurs.

For more details, refer to the GitHub issue #49491 and #49806.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-09-23 12:10:25 +02:00
Meng xianglin 7f37facddf tests: mem_protect: sys_sem: move a test case to new ztest API
move test case test_sem_take_timeout_fails() to new ztest API

Signed-off-by: Meng xianglin <xianglinx.meng@intel.com>
2022-09-22 16:42:51 +00:00
Chen Peng1 02f5e14b65 test: timer: behavior: Enhancement for running this test
Zephyr timer is based on system ticks, there usually exists some time drift
due to round up/down errors between cycles, ticks and time delay, we
need to add those expected time drift into the bound calculation for
running this test.
Add a new config TIMER_TEST_PERIOD_MAX_DRIFT_PERCENT for users to set
expected maximum drift percentage for the timer period.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-09-21 18:43:11 +00:00
Erwan Gouriou 9293222d25 tests: kernel: tickless: Don't run on nucleo_l073rz
Tickless test enables PM which implies use of LPTIM as ticker on STM32
platforms.
Specifically on nucleo_l073rz, this configuration is fragile as only
LSI(37KHz) could be used as LPTIM tick source, whith a huge accuracy
tolerance (20%).
This works on most cases, when a specific tick freq (4000 ticks/sec),
but this tests explicitly requires tick frequency set to 100.

Excludes nucleo_l073rz for this test.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-09-21 18:39:07 +00: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
Fabio Baltieri 7c231e3e27 tests: work_queue: initialize msg
Make sure msg is initialized before being used, fixes compiler warning:

  main.c:735:9: error: 'msg' may be used uninitialized

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-09-19 19:15:59 +00:00
Andy Ross 8ac135d7a9 tests/kernel/smp: Correct parameter name
The k_sys_fatal_error_handler() function is declared in zephyr/fatal.h
with a name of "esf" for the second parameter, not "pEsf".  For
unknown reasons, this is showing up in CI as a documentation
generation failure pointing at the (correct) header.

Still, no reason not to synchronize.

Signed-off-by: Andy Ross <andyross@google.com>
2022-09-19 09:19:02 +02:00
Andy Ross 358355a23d tests/kernel/smp: Fix cases for !SCHED_IPI_SUPPORTED
Obviously the test of the feature won't work if we don't have an IPI.
And there were two threads that spawned threads that enter busy loops,
expecting to be able to abort them from another CPU.  That doesn't
work[1] without an IPI.  Just skip these cases rather than trying to
kludge up some kind of abort signal.

[1] Rather, it does work, it just takes infinite time for these
    particular test cases.  Eventually the CPU would be expected to
    receive some other interrupt like a timeout, which would work to
    abort the running thread.  But no such timer was registered.

Signed-off-by: Andy Ross <andyross@google.com>
2022-09-19 09:19:02 +02:00
Michał Barnaś 1ea41b34c6 ztest: improve some tests
This commit changes some tests from using zassert_equal to validate
the pointers to using the zassert_is_null and zassert_not_null.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-09-09 07:05:38 -04: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
Mateusz Sierszulski 333bc736f3 Revert "tests: kernel: gen_isr_table: Disable RISC-V direct ISR test"
This reverts commit 857f42570c.

Signed-off-by: Mateusz Sierszulski <msierszulski@antmicro.com>
2022-09-08 10:39:31 +02:00
Anas Nashif e1c123cd3e doc: doxygen: group smp tests
Put all smp tests under one group.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-09-07 10:36:25 +02:00
Anas Nashif 0050bd98b2 doc: doxygen: move lifo tests to test group
Put all tests under one parent group.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-09-07 10:36:25 +02:00
Tom Burdick 897ae4a2d5 test: timer_behavior: Rename readme.md to readme
Renames the file to avoid what appears to be automatic inclusion
into the root of the doctree.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-09-06 17:54:52 -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
Stephanos Ioannidis 857f42570c tests: kernel: gen_isr_table: Disable RISC-V direct ISR test
This commit disables the RISC-V direct ISR test due to the broken
`vectors` section placement with the IRQ vector table enabled,
introduced by the commit d2f8ec70235208f4a70e371ccb1ed8dfe0f573c5.

For more details, refer to the GitHub issue #49903 tracking this bug.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-09-05 19:15:24 +09:00
Ruibin Chang 692054aaee tests/kernel/timer/timer_api: modify logic for longer real time
SYS_CLOCK_TICKS_PER_SEC of it8xxx2 is 4096 (244us).
Running test_sleep_abs item on it8xxx2 and we get
k_us_to_ticks_ceil32(250) = 2 and late = 2, so it failed.
After we enable the CONFIG_PM, it needs more time to resume
from low power mode, so I modify the logic to <= for passing
the test.

fixes #49605

Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2022-09-05 10:17:43 +02:00
Tom Burdick c4192f61b1 test: timer: Disable nsim_em
The test will always fail on emulated/simulated environments. Exclude
this one which was failing.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-09-02 11:04:23 +00: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
Dino Li e2ddea6b3b tests: exception/riscv: trigger illegal instruction from text section
This change ensures the exception can be triggered on RISC-V boards.
fixes: #49462

Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
2022-08-31 21:55:29 +00:00
Daniel Leung 7019baf6ac tests: kernel/smp: don't use stack to pass thread args
Inside test_get_cpu, the current CPU ID is stored in the test
thread's stack. Another thread is spawned with a pointer to
the variable holding this CPU ID, where this thread is supposed
to run on another CPU. On a cache incoherent platform, this
value of this variable may not have been updated on other CPU's
internal cache. Therefore when checking CPU IDs inside the newly
spawned thread, it is not checking the passed in CPU ID, but
actually whatever is on the another CPU's cache. This results in
random failure on the test_get_cpu test. Since for cache
incoherence architectures, CONFIG_KERNEL_COHERENCE is enabled by
default on SMP where shared data is placed in multiprocessor
coherent (generally "uncached") memory. The fix to this is to
simply make this variable as a global variable, as global
variable are consided shared data and will be placed in
multiprocessor coherent memory, and thus the correct value will
be referenced inside the newly spawned thread.

Fixes #49442

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-08-31 10:41:16 +02:00
Daniel Leung dbe3874079 tests: kernel/smp: wait for threads to exits between tests
This adds a bunch of k_thread_join() to make sure threads spawned
for a test are no longer running between exiting that test. This
prevents interference between tests if some threads are still
running when assumed not.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-08-31 10:41:16 +02:00
Stephanos Ioannidis 461db490fd tests: kernel: poll: Disable on qemu_arc_hs6x
This commit disables the `kernel.poll` test on `qemu_arc_hs6x` because
it fails at run-time when compiled with GCC 12.

Revert this commit when the GitHub issue #49492, which tracks this bug,
is fixed.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-29 16:57:18 +02:00
Stephanos Ioannidis 7d8a119213 tests: kernel: interrupt: Disable on ARM64 QEMU targets
This commit disables the `arch.interrupt` test on the ARM64 QEMU
targets (`qemu_cortex_a53` and `qemu_cortex_a53_smp`) because the
nested interrupt test fails when compiled with GCC 12.

Revert this commit when the GitHub issue #49491, which tracks this bug,
is fixed.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-29 16:57:18 +02:00
Evgeniy Paltsev 5108c4f21d tests: allow ARC platforms for non-multithread tests
Allow arc non-SMP simulation platforms for non-multithread tests

Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2022-08-26 21:38:56 -04:00
NingX Zhao 2ce20e5df6 tests: kernel: mheap: migrate mheap testcases
Move testcases to new ZTEST API.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-25 13:12:04 -04:00
Kumar Gala 7b1a8f4b89 tests: timer: timer_behavior: Fix compile issues
Includes need to be <zephyr/tc_util.h> and <zephyr/ztest.h> otherwise
we get build errors.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-24 15:53:50 -05:00
Tom Burdick fafb4d70b5 kernel: Timer behavioral testing
Test and validate the behavior of a timer driver.

Takes a number of absolute timer cycle samples of a periodic timer then
calculates statistical mean, variance, stddev along with total drift over
the entire test time. Ensures standard deviation and drift are within
a given configurable bound.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-08-24 13:59:24 -04:00
NingX Zhao f02c528aab tests: kernel: workq: migrate user work testcases
Move test cases to new ZTEST API.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-24 17:48:26 +00:00
NingX Zhao b2c64dee27 tests: kernel: workq: migrate work_queue test cases
Move work_queue testcases to new ZTEST API.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-24 17:48:26 +00:00
NingX Zhao d4e2e883d7 tests: kernel: workq: migrate workq testcases.
Move test cases to new ZTEST API.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-24 17:48:26 +00:00
NingX Zhao 69c89b1acd tests: kernel: workq: move critical test cases to new ZTEST
Move critical test cases to new ZTEST API.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-24 17:48:26 +00:00
Guo Lixin 80f848e4a4 tests: kernel: early_sleep: move to new ztest API
Move tests/kernel/early_sleep/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-08-23 20:57:04 -04:00
Enjia Mai 7dcab41b4c tests: kernel: move the sys_sem test to new ztest API
Migrate the testsuite tests/kernel/mem_protect/sys_sem to the
new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-19 20:44:49 +00:00
Enjia Mai 00fedc2eb2 tests: kernel: move the test demand_paging to new ztest API
Migrate the testsuite tests/kernel/mem_protect/demand_paging to
the new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-19 20:44:49 +00:00
Enjia Mai 7684f46b7f tests: kernel: move the memory protection test to new ztest API
Migrate the testsuite tests/kernel/mem_protect/mem_protect to
the new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-19 20:44:49 +00:00
Enjia Mai 8ea5cea4a7 tests: kernel: move the userspace test to new ztest API
Migrate the testsuite tests/kernel/mem_protect/userspace to the
new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-19 20:44:49 +00:00
Enjia Mai 09abe3b6a6 tests: kernel: move the test futex to new ztest API
Migrate the testsuite tests/kernel/mem_protect/futex to the
new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-19 20:44:49 +00:00
Ming Shao 3516bd7358 tests: fix the wrong test config name in schedule_api test
The kernel.scheduler.dumb_no_timeslicing is duplicated.
Should be kernel.scheduler.dumb_timeslicing.
Otherwise, there'll be only 7 test configurations while
actually there should be 8.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-19 12:10:14 +02:00
Ming Shao 3d1782338b tests: add the missing initialization in test_slice_scheduling
The global variable thread_idx should be properly initialized
for test_slice_scheduling. This issue is found when run the
test repeatedly with the new ztest fx.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-19 12:10:14 +02:00
Ming Shao c46139a8bd tests: kernel: metairq: move to new ztest API
Move tests/kernel/sched/metairq to new ztest API.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-19 12:10:14 +02:00
Ming Shao 7061dbf96b tests: use dynamic threads in metairq test
Old implementation of tests/kernel/sched/metairq used
static threads. The new ztest fx doesn't support static
threads for repeated test execution.(See issue: #48018)

So change to use dynamic threads to embrace the new
ztest fx.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-19 12:10:14 +02:00
Ming Shao 055aa738f0 tests: kernel: preempt: move to new ztest API
Move tests/kernel/sched/preempt to new ztest API.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-19 12:10:14 +02:00
Ming Shao 80f8540f9b tests: add ending logic for the preempt test
Old tests/kernel/sched/preempt cannot be run repeatedly.
If you register the test_preempt() method twice, the
second run will fail. It is because the participating
threads don't exit properly when the main thread exits.

The new ztest fx implies that a unit test should be able
to run repeatedly. This commit enables that for the preempt
test by adding explicit epilogue.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-19 12:10:14 +02:00
Ming Shao 392cabe070 tests: kernel: deadline: move to new ztest API
Move tests/kernel/sched/deadline to new Ztest API.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-19 12:10:14 +02:00
Ming Shao 170b8254aa tests: add initialization for the deadline test
The deadline test should initialize the n_exec so
that it can be executed repeatedly and in a shuffled
way with other tests, which is a paradigm offered
by the new ztest fx.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-19 12:10:14 +02:00
Ming Shao ec8a3ba7a8 tests: kernel: scheule_api: move to new ztest API
Move tests/kernel/sched/schedule_api to new ztest API.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-19 12:10:14 +02:00
Daniel Leung fd8ffdb833 boards: qemu_x86_tiny: enable support for coverage
This adds the bits so that we can use qemu_x86_tiny for
coverage, as this is currently the only board that can do
demand paging.

This uses the board revision as a way to specify the RAM
size as coverage requires more memory available to store
the coverage data. By piggybacking onto board revision,
this avoids adding another board config just for coverage.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-08-18 17:23:18 +02:00
Peter Mitsis 029035cbea tests: Add CONFIG_PIPES to tests that use pipes
Use of pipes is now configurable. All tests that use pipes must enable
that feature. (Note: no sample projects currently use pipes.)

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-08-17 19:31:25 +02:00
Meng xianglin 0a56d86b39 tests: sys_sem: add cleanup to test case
with CONFIG_ZTEST_NEW_API, test cases can be run in any order, every
test case need to do necessary cleanup.

Signed-off-by: Meng xianglin <xianglinx.meng@intel.com>
2022-08-17 15:49:12 +00:00
Meng xianglin f039c8b0e5 test: sys_sem: move to new ztest API
all test cases in tests/kernel/semaphore/sys_sem/ are moved to
new ztest API

Signed-off-by: Meng xianglin <xianglinx.meng@intel.com>
2022-08-17 15:49:12 +00:00
Meng xianglin bea19cc38a test: semaphore: move to new ztest API
test cases in tests/kernel/semaphore/semaphore are moved
to new ztest API

Signed-off-by: Meng xianglin <xianglinx.meng@intel.com>
2022-08-17 15:49:12 +00:00
NingX Zhao 6bd291151b tests: kernel: poll: move the testcase to new ZTEST API
Move test cases to the new ZTEST API.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-17 08:14:10 +00:00
Manuel Arguelles 7f26c1c25c tests: samples: revert timeout change for FVP BaseR
Partially revert commit 0028e9733295316d152eba07bf56677d83f4b1b5.
Timeout for tests/posix/common must be still increased for slow
platforms (previously was 120 sec).

Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
2022-08-16 15:51:38 +02:00
Enjia Mai 29e66ff6dd tests: kernel: mbox: add extra stack size
After moving the mbox_api test to new ztest API, one test failed
due to stack overflow on qemu_x86_lakemont. Add a little 64 extra
stack size for adapting it.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-15 18:40:49 +00:00
Enjia Mai 0b93aaa6a4 tests: kernel: move the test mbox_api to new ztest API
Migrate the testsuite tests/kernel/mbox/mbox_api to the new
ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-15 18:40:49 +00:00
Enjia Mai ce024927e4 tests: kernel: move the test mbox_usage to new ztest API
Migrate the testsuite tests/kernel/mbox/mbox_usage to the new
ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-15 18:40:49 +00:00
Enjia Mai ce3ab2f9ed tests: kernel: move the timer api to new ztest API
Migrate the testsuite tests/kernel/timer/timer_api
to new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-15 18:40:29 +00:00
Enjia Mai 94c6dafb8d tests: kernel: move the timer error case to new ztest API
Migrate the testsuite tests/kernel/timer/timer_error_case
to new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-15 18:40:29 +00:00
Enjia Mai 2d25d3c117 tests: kernel: timer: move the test monotonic to new ztest API
Migrate the testsuite tests/kernel/timer/timer_monotonic to
the new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-15 18:40:29 +00:00
Enjia Mai 37b8b5ba0e tests: kernel: timer: move the test starve to new ztest API
Migrate the testsuite tests/kernel/timer/starve to the new
ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-15 18:40:29 +00:00
Enjia Mai 34c80f2bfa tests: kernel: timer: move the test cycle64 to new ztest API
Migrate the testsuite tests/kernel/timer/cycle64 to the new
ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-15 18:40:29 +00:00
NingX Zhao 9ec1406134 tests: kernel: mslab: move threadsafe case to new ZTEST
move threadsafe test cases to new ZTEST API.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-15 08:22:21 +00:00
NingX Zhao aec0f624ee tests: kernel: mslab: move concept cases to new ZTEST API
Move concept test cases to new ZTEST API.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-15 08:22:21 +00:00
NingX Zhao b42c04deeb tests: kernel: mslab: move api the testcases to new API
Move mslab api testcases to new ZTEST api.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-15 08:22:21 +00:00
NingX Zhao 750bc68028 tests: kernel: mslab: move testcases to new ZTEST API
Move test cases of the mslab to new ZTEST API.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-15 08:22:21 +00:00
NingX Zhao 1eea3c02b6 kernel: thread: move thread tls testcase to new ztest
Move thread tls testcases to new ztest.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-12 17:39:03 +02:00
NingX Zhao c81a267bc5 kernel: thread: move thread stack testcase to new ztest
Move thread stack testcases to new ztest.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-12 17:39:03 +02:00
NingX Zhao 70c6819859 kernel: thread: move thread init testcase to new ztest
Do some changes to make sure the testcases are independent.
Move thread init testcases to new ztest.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-12 17:39:03 +02:00
NingX Zhao 89dc84b389 kernel: thread: move thread error case to new ztest
Move thread error testcases to new ztest.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-12 17:39:03 +02:00
NingX Zhao 7f8cad9956 kernel: thread: move thread api testcase to new ztest
Move thread apis testcases to new ztest.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-12 17:39:03 +02:00
NingX Zhao 5e1747c1e6 kernel: thread: move no-multithreading testcase to new ztest
Move thread no-multithreading testcases to new ztest.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-12 17:39:03 +02:00
NingX Zhao b1a82a039d kernel: thread: move thread dynamic cases to new ztest
Move thread dynamic testcases to new ztest.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-12 17:39:03 +02:00
Meng xianglin 0e21bb855e tests: msgq_usage: move to new ztest API
test cases in tests/kernel/msgq/msgq_usage are moved to new ztest API

Signed-off-by: Meng xianglin <xianglinx.meng@intel.com>
2022-08-12 11:31:11 +02:00
Meng xianglin cd66ee67a7 tests: msgq_api: move to new ztest API
test cases in tests/kernel/msgq/msgq_api/ are move to new ztest API

Signed-off-by: Meng xianglin <xianglinx.meng@intel.com>
2022-08-12 11:31:11 +02:00
Enjia Mai fd1cd21aff tests: kernel: move the multiprocessing test to new ztest
Migrate the testsuite tests/kernel/mp to the new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-11 12:19:59 +02:00
NingX Zhao 5f681dea38 kernel: heap: move heap testcase to new ztest
Move heap testcases to new ztest.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-10 12:57:36 -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
NingX Zhao 9ba764bbf0 kernel: queue: move queue testcase to new ztest
Move queue testcases to new ztest.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-08-05 11:46:59 +01:00
Guo Lixin 0356e1a925 tests: kernel: context: move to new ztest API
Move tests/kernel/context/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-08-04 13:42:47 +02:00
Ming Shao 99fff9ff03 tests: kernel: syst_mutex: move to new ztest API
Move sys_mutex tests to new ztest API.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-03 18:43:42 +02:00
Ming Shao e3fad7be40 tests: Enhance the thread_competition case in sys_mutex test
Current thread_competition() case cannot verify the order of mutex
taking. This commit enhances on that.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-03 18:43:42 +02:00
Ming Shao 2daae30ec3 tests: Use dynamic thread instead of static thread for sys_mutex test
As of now, both the old and new ztest framework don't have a logic to
launch static threads. Static threads can only be launched by Zephyr
itself during boot.  If a test interact with static threads, when it
is executed multiple times without reboot, only the first few runs can
have static threads to interact with. After the static threads exit,
later runs will have nothing to interact with, which can lead to failure.
One unfortunate example is the sys_mutex test.
This commit replaces static threads with dynamic thread to make the test
repeatable. In future, maybe static threads launching logic should  be
covered by the ztest framework so richer scenarios can be tested.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-03 18:43:42 +02:00
Ming Shao e77d233981 tests: kernel: mutex_error_case: move to new ztest API
Move mutex_error_case tests to new ztest API.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-03 18:43:42 +02:00
Ming Shao 4a0ce498d1 tests: kernel: mutex_api: move to new ztest API
Move mutex_api tests to new ztest API.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-08-03 18:43:42 +02:00
Gerard Marull-Paretas 44250fe3d3 soc: arch: synopsys: move timer0/1 IRQ information to DT
timer0/1 IRQ information was hardcoded in soc.h, however, Devicetree is
nowadays a better place to describe hardware. Note that I have followed
existing upstream Linux code to do these changes.

Ref.
- https://elixir.bootlin.com/linux/latest/source/arch/arc/boot/dts/
  hsdk.dts
- https://elixir.bootlin.com/linux/latest/source/Documentation/
  devicetree/bindings/timer/snps,arc-timer.txt

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-03 07:46:14 -04:00
Julius Barendt e54cc1f6d1 tests: fpu_sharing/generic: Remove qemu_leon3 workaround
This workaround is no longer needed as sparc stack footprint
is reduced in this commit:
5cf2083e8b87f918a522423a1659ae58137ceea0

Signed-off-by: Julius Barendt <julius.barendt@gaisler.com>
2022-08-03 12:05:49 +02:00
Stephanos Ioannidis e4d83147a2 tests: kernel: exception: Disable infinite recursion warning
This commit disables the infinite recursion warning
(`-Winfinite-recursion`), which may be reported by the GCC 12 and
above, for the `stack_smasher` function because that is the intended
behaviour.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-03 05:03:28 +01: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
Stephanos Ioannidis df3d4d27a4 tests: kernel: sleep: Fix uninitialised variable warning
This commit sets an initial value of 0 for the `elapsed_ms` variable,
which may be used uninitialised when the while loop below does not
execute.

This fixes the "‘elapsed_ms’ may be used uninitialized" warning
generated by the GCC 12.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-07-29 09:19:14 -04:00
Guo Lixin 5f7d50c49a tests: kernel: pending: move to new ztest API
Move tests/kernel/pending/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-25 15:49:03 -04:00
Andrew Jackson e183671808 kernel: Add k_event_set_masked primitive
There is no easy way to clear event bits without
the potential for a race to exist between producer(s)
and consumer(s). The result of this race is that events
can be lost through the various resetting mechanisms
available (flag to k_event_wait(), or k_event_set()).

Add k_event_set_masked() which permits bits to be set or cleared.
This allows consumers to clear just the bits that they have read
without (accidentally) discarding any new bits.

Update unit tests to verify the functionality.

Partly Fixes #46117.

Signed-off-by: Andrew Jackson <andrew.jackson@amd.com>
2022-07-25 15:24:32 -04:00
Guo Lixin d6995cb050 tests: fpu_sharing/generic: workaround crash on qemu_leon3
When running tests/kernel/fpu_sharing/generic on qemu_leon3 with the
new ztest API, a fatal error is raised while test is reported success.
So workaround this by changing the main stack size to 2048.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-18 12:20:39 -04:00
Guo Lixin 948cb6a8d9 tests: kernel: generic: move to new ztest API
Move tests/kernel/fpu_sharing/generic/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-18 12:20:39 -04:00
Guo Lixin 4f37c99601 tests: kernel: float_disable: move to new ztest API
Move tests/kernel/fpu_sharing/float_disable/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-18 12:20:39 -04: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 6433cfb2ec tests: kernel: profiling: move to new ztest API
Move tests/kernel/profiling/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-18 13:23:49 +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
Johann Fischer d66e047e5b tests: use unsigned int for irq_lock()
irq_lock() returns an unsigned integer key.
Generated by spatch using semantic patch
scripts/coccinelle/irq_lock.cocci

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-07-14 14:37:13 -05:00
Enjia Mai 4a3184441c tests: kernel: mem_protect: move the obj validation test to new ztest
Migrate the testsuite tests/kernel/mem_protect/obj_validation
to the new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-07-14 10:29:33 +02:00
Enjia Mai a3d834ed2b tests: kernel: mem_protect: move the syscalls test to new ztest
Migrate the testsuite tests/kernel/mem_protect/syscalls to
the new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-07-14 10:29:33 +02:00
Enjia Mai 72d4ac27ad tests: kernel: mem_protect: move the protection test to new ztest
Migrate the testsuite tests/kernel/mem_protect/protection to
the new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-07-14 10:29:33 +02:00
Enjia Mai 4df4646aa1 tests: kernel: mem_protect: move the stack random test to new ztest
Migrate the testsuite tests/kernel/mem_protect/stack_random to the new
ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-07-14 10:29:33 +02:00
Enjia Mai b479838e0a tests: kernel: mem_protect: move the stack protection test to new ztest
Migrate the testsuite tests/kernel/mem_protect/stackprot to the new
ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-07-14 10:29:33 +02:00
Enjia Mai 87f0b58efe tests: kernel: mem_protect: move the mem map test to new ztest API
Migrate the testsuite tests/kernel/mem_protect/mem_map to the new
ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-07-14 10:29:33 +02:00
Enjia Mai b7f1e98724 tests: kernel: move the interrupt tests to new ztest API
Migrate the testsuite tests/kernel/interrupt to the new ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-07-12 13:21:47 -04:00
Enjia Mai b3d442ec87 tests: kernel: move the direct interrupt test to arch testing
Move the direct interrupt test to tests/arch/x86/direct_isr. Two
reasons:
1. The direct interrupt is only for x86. It's arch-specific.
2. And it need extra gcc option to pass the build, that will
include testsuite number. Although it seems like we add a
extra testsuite for it, actually we can reduce whole tests
configuration in tests/kernel/interrupt. And also make this
test more generic as it used to be.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-07-12 13:21:47 -04:00
Guo Lixin b2532e3fb7 tests: kernel: stack: move to new ztest API
Move tests/kernel/stack/ to use new ztest API.
And make test case a little more independent.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-12 10:02:58 -04:00
Guo Lixin 800253aeea tests: kernel: lifo_usage: move to new ztest API
Move tests/kernel/lifo/lifo_usage/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-12 10:02:33 -04:00
Guo Lixin 9ebc1b0954 tests: kernel: lifo_api: move to new ztest API
Move tests/kernel/lifo/lifo_api/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-12 10:02:33 -04:00
Peter Mitsis 4c1d33a436 tests: Add mslab_stats test
This test case verifies that the mem slab runtime stats routines
behave as expected.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-07-12 13:59:26 +00:00
Guo Lixin dada9ea54b tests: kernel: gen_isr_table: move to new ztest API
Move tests/kernel/gen_isr_table/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-11 13:23:27 +02:00
Manuel Arguelles f2ae4b67b2 tests: samples: bump timeout for FVP BaseR board
Timeout must be increased for fvp_baser_aemv8r_aarch32 board. Enabling
MPU on this board makes simulation slower.

Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
2022-07-11 11:17:02 +02:00
Carlo Caione 3f8c119357 tests: shared_multi_heap: Move to new ztest API
Migrate the test to the new ztest API.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-07-08 20:13:04 +00:00
Guo Lixin dd5463a5ed tests: kernel: xip: move to new ztest API
Move test to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-08 20:10:59 +00:00
Guo Lixin ce56056c30 tests: kernel: fifo_usage: move to new ztest API
Move tests/kernel/fifo/fifo_usage/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-08 12:04:21 +02:00
Guo Lixin f95bae9962 tests: kernel: fifo_timeout: move to new ztest API
Move tests/kernel/fifo/fifo_timeout/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-08 12:04:21 +02:00
Guo Lixin 0f9050544a tests: kernel: fifo_api: move to new ztest API
Move tests/kernel/fifo/fifo_api/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-08 12:04:21 +02:00
Guo Lixin 94078d3d8f tests: kernel: sleep: move to new ztest API
Move tests/kernel/sleep/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-08 12:02:18 +02:00
Carlo Caione e3f3aba989 arch: Use a common place for z_irq_spurious
Every architecture must export the z_irq_spurious definition. Just unify
that in one single header file.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-07-07 15:24:39 -04:00
Guo Lixin ddfde93436 tests: kernel: usage: move to new ztest API
Move tests/kernel/usage/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-07 10:13:23 +02:00
Guo Lixin c40afb7059 tests: kernel: tickless: move to new ztest API
Move tests/kernel/tickless/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-07 10:07:58 +02:00
Carlo Caione 3a5e54d602 gen_isr_table: Exclude m2gl025_miv from test
Apparently m2gl025_miv does not support vectored mode. Exclude from
test.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-07-07 10:00:20 +02:00
Carlo Caione fe19420f93 test: gen_isr_table: Fix test for RISCV
Fix this test adding a proper support for RISCV when in vectored mode
with IRQ vector table generation.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-07-07 10:00:20 +02:00
Guo Lixin 9588ecdba8 tests: no-multithreading: move to new ztest API
Move tests/kernel/fatal/no-multithreading/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-06 21:09:55 -04:00
Guo Lixin 6a254c7fb6 tests: kernel: exception: move to new ztest API
Move tests/kernel/fatal/exception/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-06 21:09:55 -04:00
Anas Nashif 02f2896586 tests: add mising braces to single line if statements
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-06 11:00:45 -04:00
Jordan Yates 201902bda1 tests: device: validate SYS_INIT_NAMED
Check that `SYS_INIT_NAMED` allows multiple instances of the same
initialisation function, as long as names are unique.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-06 10:44:35 +02:00
Guo Lixin 05c13ac094 tests: kernel: pipe_api: move to new ztest API
Move tests/kernel/pipe/pipe_api/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-05 11:13:00 -04:00
Guo Lixin af1e0c5a00 tests: pipe: move to new ztest API
Move tests/kernel/pipe/pipe/ to use new ztest API.
And make test case a little more independent.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-05 11:13:00 -04:00
Guo Lixin 4c3b7f3785 tests: kernel: sys_event: move to new ztest API
Move tests/kernel/events/sys_event/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-05 09:52:49 -04:00
Guo Lixin 31cc0a20af tests: kernel: event_api: move to new ztest API
Move tests/kernel/events/event_api/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-05 09:52:49 -04:00
Guo Lixin 213eaeee79 tests: kernel: spinlock: move to new ztest API
Move test to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-04 06:54:31 -04:00
Guo Lixin f137e24e3b tests: kernel: smp: move to new ztest API
Move tests/kernel/smp/ to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-01 14:04:22 -04:00
Guo Lixin c015277730 tests: kernel: device: move to new ztest API
Move tests/kernel/device to new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-01 18:00:40 +00:00
Guo Lixin e9ae9dd622 tests: kernel: smp_boot_delay: move to new ztest API
Move tests/kernel/smp_boot_delay to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-01 16:37:17 +00:00
Guo Lixin 0a53b0b4a2 tests: kernel: obj_tracking: move to new ztest API
Move test to use new ztest API.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-07-01 16:37:04 +00:00
Andy Ross b65277990a tests/kernel/context: Fixup slop in cpu_idle test case
This test was written to idle for exactly 1ms and wake up with zero
error, which is just too tight for some platforms (and worked on
emulators where the tick rate is 10x coarser only because 0 == 0!).

And it's not clear that it's testing anything we promise in
documentation, regardless.  Early wakeups are not an error and
absolutely not disallowed, yet the test is treating the wakeup like a
sleep.

Clean it up a bit and relax the tolerance to what we can compute
reliably: do all the math in ticks, idle for 10ms (i.e. longer than a
host quantum for emulators), and allow 1 tick of slop on either side to
permit slightly early wakeups while still verifying that "yes, the idle
did idle".

Fixes #46641

Signed-off-by: Andy Ross <andyross@google.com>
2022-07-01 11:37:54 +02:00
Andrei Emeltchenko 66cfe4f430 tests: mem_protect: Fix checking wrong variable
At the moment zassert_is_null() is checking value which is always NULL.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-30 12:37:14 -05:00