Commit graph

2591 commits

Author SHA1 Message Date
Yong Cong Sin ad788a335f tests: interrupt: add testcase for functions in the sw_isr_table
Validate the following functions in the sw_isr_table:
- z_get_sw_isr_table_idx
- z_get_sw_isr_device_from_irq
- z_get_sw_isr_irq_from_device

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-11-09 11:20:42 +01:00
Evgeniy Paltsev c5cd886518 test: spinlock: cleanup assertion
Don't double check on assertion condition.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-11-06 15:44:34 -06:00
Francois Ramu 0dcaa4c668 boards: arm: stm32f746 with all mpu regions when testing in userspace
Disable the  quadspi mpu region of the nucleo_f746zg
when testing the samples/userspace/shared_mem
or tests/kernel/mem_protect/userspace
The stm32f7 cortex M7 has 8 MPU regions and the one for quadspi prevents
the testcase to PASS.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-11-06 12:32:08 +01:00
Andrei Emeltchenko fa6c281d82 tests: thread_apis: Change printk and TC_PRINT to LOG
Replace combination of printk() and TC_PRINT() to LOG_DBG() disabled
by default so that it does not affect execution time.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-11-06 10:08:27 +01:00
Andrei Emeltchenko 84317da082 tests: thread_apis: Make local functions static
Most of the local functions are static, make code consistent by making
remaining functions static as well.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-11-06 10:08:27 +01:00
Andrei Emeltchenko a6da17aab4 tests: k_mbox: Change ZTEST_USER to ZTEST
Since userspace is not enabled change ZTEST_USER to ZTEST to not
confuse people, other tests are also ZTEST.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-11-05 07:51:59 -05:00
Andrei Emeltchenko 6247dddcb5 tests: k_mbox: Remove unneeded k_sleep()
The test_multi_thread_send_get() test sends and receives mbox messages
with K_FOREVER as timeout, so k_sleep() is not needed here.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-11-05 07:51:59 -05:00
Andrei Emeltchenko 6308528e5b tests: k_mbox: Simplify code and check return code
k_mbox_get() / k_mbox_put() get timeout as is, so there is no need for
extra code. Also check that k_mbox_put() actually sends message.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-11-05 07:51:59 -05:00
Alexander Razinkov 5725585112 tests: kernel: common: added test on atomic_t overflow
Added test to verify that the value of atomic_t will be the same
in case of overflow if incremented in atomic and non-atomic manner

Signed-off-by: Alexander Razinkov <alexander.razinkov@syntacore.com>
2023-11-04 07:38:39 -04:00
Alexander Razinkov 8fe8f34169 tests: kernel: spinlock: acquisition fairness test
Added test to verify the spinlock acquisition fairness
in relation to the CPUs contending for the spinlock.
This test is only enabled for Ticket Spinlocks which
required to provide such kind of fairness.

Signed-off-by: Alexander Razinkov <alexander.razinkov@syntacore.com>
2023-11-04 07:38:39 -04:00
Anas Nashif a08bfeb49c syscall: rename Z_OOPS -> K_OOPS
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 9c4d881183 syscall: rename Z_SYSCALL_ to K_SYSCALL_
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 9c1aeb5fd3 syscall: rename z_user_ to k_usermode_
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 70e791905d syscall: rename z_user_string_nlen -> k_usermode_string_nlen
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 21254b2f40 syscall: rename z_object_validate -> k_object_validate
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif c25d0804f0 syscall: rename z_object_find -> k_object_find
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 43a7402baf syscall: rename z_object_recycle -> k_object_recycle
Rename z_object_recycle and do not use z_ for internal APIs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif d178b6a0e7 syscall: z_obj_validation_check -> k_object_validation_check
Rename z_obj_validation_check  and do not use z_ for internal APIs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 4d5d04169d syscall: rename z_is_in_user_syscall
Rename z_is_in_user_syscall -> k_is_in_user_syscall

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 4e396174ce kernel: move syscall_handler.h to internal include directory
Move the syscall_handler.h header, used internally only to a dedicated
internal folder that should not be used outside of Zephyr.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif a6b490073e kernel: object: rename z_object -> k_object
Do not use z_ for internal structures and rename to k_object instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif c91cad735a kernel: object: rename z_object_init to k_object_init
Do not use z_ for internal API and rename to k_object_init.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif c54fb959e3 kernel: objects: rename z_dynamic_object_aligned_create
Do not use z_ for internal APIs and rename function.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Benedikt Schmidt d28262905e tests: kernel: fix thread function signatures
Fix thread function signatures to avoid stack corruption on exit.
Fixes #64578

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 17:45:59 +00:00
Yong Cong Sin d7302f417e irq: relocate multi-level irq out of irq.h
Relocate multi-level interrupts APIs out of `irq.h` into
a new file named `irq_multilevel.h` to provide cleaner
separation between typical irq & multilevel ones.

Added preprocessor versions of `irq_to_level_x` as `IRQ_TO_Lx`.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-10-30 11:43:39 -04:00
Andrei Emeltchenko c243991000 tests: work_queue: Change TC_PRINT to LOG_DBG
There are many TC_PRINT()'s in the work_queue test and it make sense
to change them to LOG_DBG() which are disabled by default. Other issue
is that some of TC_PRINT() are inside works for which execution time
is measured.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-10-30 09:29:25 -04:00
Benedikt Schmidt aa25e212d1 tests: fix thread function signatures
Fix thread function signatures to avoid stack corruption on thread exit.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 12:24:34 +01:00
Andrei Emeltchenko daa739a410 tests: spinlock: Clear test globals before each test
Clear test global variables before each test execution.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-10-26 10:30:24 -04:00
Peter Mitsis 9f7244ee04 tests: obj_core: Increase stack sizes
Increase the size of the thread stacks used by the obj_core tests
by CONFIG_TEST_EXTRA_STACK_SIZE bytes. This is useful to prevent
stack overflow/corruption when options such such as
    "--coverage --gcov-tool gcov"
are applied to twister runs.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-10-25 10:05:52 +02:00
Alberto Escolar Piedras fb38b90481 tests kernel: Exclude posix arch for userspace tests
These tests cannot be run in this architecture as it does not
support userspace.
Today they are filtered by kconfig, which works but spends
time running cmake.
As native_posix is a default test platform it is better
to filter it alltogether by arch, which saves quite a lot
of time.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-24 09:05:29 +02:00
Flavio Ceolin 564adad952 treewide: Add CODE_UNREACHABLE after k_thread_abort(current)
Compiler can't tell that k_thread_abort() won't return and issues a
warning unless we tell it that control never gets this far.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-24 09:04:42 +02:00
Andrei Emeltchenko 1860af4bf4 tests: profiling: Remove unused Kconfig
Remove unused Kconfig with unused KERNEL_PROFILING_API_TEST.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-10-22 19:08:26 -04:00
Anas Nashif 996c8457d7 ztest: remove old ztest api
Remove old Ztest API entirely. New API is the now the default.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-20 15:04:29 +02:00
Anas Nashif 345735d0a8 tests: remove CONFIG_ZTEST_NEW_API in all tests
Remove all usage of CONFIG_ZTEST_NEW_API from tests and sample as this
is now enabled by default.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-20 15:04:29 +02:00
Peter Mitsis e9987aabbc kernel: Remove legacy mem block from mailbox
Memory blocks are a legacy feature and are to be removed from
mailboxes.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-10-13 09:56:02 +03:00
Fabio Baltieri a16d58cdf3 Revert "tests: kernel: xip: exclude qemu_riscv32_xip"
This reverts commit 341590545a, the issue
has been fixed in e1647e35c0, tested with

west build -t run -p -b qemu_riscv32_xip \
	-T tests/kernel/xip/arch.common.xip

west build -t run -p -b qemu_riscv32_xip \
	-T tests/kernel/xip/arch.common.xip.minimallibc

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-10-12 17:23:40 +01:00
Anas Nashif b2af50a836 tests: object cores: fix test meta data and components
Fix meta data and standarize components in test identifiers.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-11 14:19:40 +03:00
Flavio Ceolin e7bd10ae71 random: Rename random header
rand32.h does not make much sense, since the random subsystem
provides more APIs than just getting a random 32 bits value.

Rename it to random.h and get consistently with other
subsystems.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-10 14:23:50 +03:00
Keith Packard 1b057d6295 tests/timer_api: Make sure constant time conversions are constants
When the timer frequency is known at compile time, make sure we can use any
time conversion macro as a global initializer.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-10-06 20:05:07 +03:00
Grant Ramsay 1951d83783 tests: timer_monotonic: Add mps2_an385 test with icount disabled
This is to validate that GH-48608 is fixed
and stays fixed.

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
2023-10-05 15:30:20 +01:00
Yong Cong Sin 019ae15f05 tests: kernel: work: fix uninitialized timer's work item
The `test_1cpu_drain_wait` tests iff the thread of a work queue
that is waiting to be drained can submit work item to the
queue. A timer is created with a callback funciton to submit a
work item to the same queue, to help demonstrate that behavior.

However, the work item submitted by `test_drain_wait_cb` to the
`coophi_queue` isn't initialized, and can hit assertion if it
is processed by the work queue.

Fixes #63559

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-10-05 13:43:07 +01:00
Martin Åberg ccbbb493da tests: kernel: Add qemu_leon3 to no-multithreading tests
Add qemu_leon3 target to the tests that list below. These set
CONFIG_MULTITHREADING=n.

- tests/kernel/mem_heap/mheap_api_concept
- tests/kernel/mem_slab/mslab_api
- tests/kernel/threads/no-multithreading
- tests/kernel/timer/timer_api

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2023-10-05 09:37:10 +01:00
Anas Nashif e19f21cb27 kernel: move z_is_thread_essential out of public kernel header
This is a private API to the kernel, so move out of kernel.h

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-09-30 18:43:28 +02:00
Peter Mitsis 13712dbea2 test: Shorten object core API stats test name
Changing the name of the routine test_obj_core_stats_deregister()
to something shorter (test_obj_core_stats_dereg) has been found to
be a workaround to the issue identified in #61087.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-09-30 08:04:14 +03:00
Peter Mitsis eb86a0cca5 test: Implement obj core stats test
Adds a test to test the objects integrated into the object core
statistics framework.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-09-30 08:04:14 +03:00
Peter Mitsis d709182ba5 test: Implement object core stats API test
Creates a set of tests to verify that the top-level
k_obj_core_stats_xxx() routines behave as expected.
Note that this test is not meant to test the details
of the object core statistics operator function pointers.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-09-30 08:04:14 +03:00
Peter Mitsis 5594de49ea test: Implement object core test
Creates a test to verify that kernel objects can be found within
the object core framework.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-09-30 08:04:14 +03:00
Manuel Argüelles 3923cda6d8 tests: kernel: syscalls: use default faulty address for s32z270dc2
Before Picolibc was made default, this board needed a custom test
faulty address. Now this address does not produce a fault anymore so
switch back to the default faulty address.

Fixes #63270

Signed-off-by: Manuel Argüelles <manuel.arguelles@nxp.com>
2023-09-29 20:34:51 +03:00
Andrzej Głąbek 222593f8c4 tests: kernel: timer: jitter_drift: Restore initial alignment to tick
This is a follow-up to commit 4cc21e2f4a.

That short sleeping before starting the test was removed together with
accuracy improvements (specifically, with moving of the first readout
of the cycle counter). Nevertheless, this tick alignment it still
needed, as without it in specific conditions the test may undesirably
fail.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-09-29 16:25:10 +02:00
Daniel Leung d47b1c05f3 kernel: userspace: add k_object_is_valid()
This adds a function k_object_is_valid() to check if a kernel
object exists, of certain type, and has been initialized.
This replaces the same (or very similar) code that has been
copied from kernel into the network subsystem.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-09-28 17:28:43 -04:00
Keith Packard 4269bbc4ea test/kernel: Adjust timer test to deal with time_units macros
All of the time_units conversion routines are now macros which means the
test cannot reference them as functions. Instead, create local static
functions which call each one of them and use those instead.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-09-28 16:15:27 +02:00
Andrei Emeltchenko bf4dc31015 tests: spinlock: Make local functions static
Make local functions static.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-09-28 15:46:07 +02:00
Andrei Emeltchenko a3959af4f5 tests: spinlock: Increase thread execution to prevent quick exit
On Intel boards (like intel_ehl_crb and intel_rpl_s_crb) for the
trylock_test some part is executed very fast and since there is no
synchronization, there might be situation when there is no
trylock_failures. Increasing time spend in this part fixes the issue.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-09-28 15:46:07 +02:00
Yonatan Schachter a7df77cd99 tests: byteorder: Add tests for sys_uint*_to_array macros
Add tests for sys_uint*_to_array macros to the byteorder suite.

Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
2023-09-28 07:39:09 -04:00
Ederson de Souza 5c65a60eab tests/kernel/timer/timer_behavior: Add support for Saleae Logic 2
This patch shows an example of how to use the timer behavior external
tool testing, using the Saleae Logic 2 application.

Also, some board overlays were added as examples.

Finally, testcase.yaml updated with parameters for the Saleae sample.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2023-09-27 20:25:09 -04:00
Ederson de Souza 22ba9456de tests/kernel/timer/timer_behavior: Add support for external tool
This patch adds a way to simplify using an external tool to measure
timer behaviour on Zephyr. It modifies the timer behaviour
jitter_drift.c tests to toggle a GPIO pin (defined via a new DTS
compatible, "test-kernel-timer-behavior-external") that can be connected
to an external tool, such as a logic analyzer, to measure timer
behaviour.

This GPIO pin toggle is behind a new CONFIG_TIMER_EXTERNAL_TEST Kconfig.

A new pytest test is added so that it can collect the statistics from
the external tool and assert some measurements. To collect statistics
from the external tool, one needs to provide a Python module which
provides a `run(seconds, config)` method, that will perform the test and
return the statistics. Check the README file for more information about
this interface.

Finally, this on twister, this new test is behind a new fixture,
"gpio-timerout".

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-09-27 20:25:09 -04:00
Fabio Baltieri 341590545a tests: kernel: xip: exclude qemu_riscv32_xip
This board seems to have issue with data alignemnt after 843f66f and is
failing in CI. Exclude it while the problem is investigated.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-09-22 17:39:38 +01:00
Carlo Caione 85c4111002 memory-attr: Rationalize _MASK and _GET(x) macros
Let's make this official: we use the suffix `_MASK` for the define
carrying the GENMASK for the attributes, and the suffix `_GET(x)` for
the actual macro extracting the attributes.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-09-22 09:27:57 +02:00
Jaxson Han 2a8548b036 tests: Kernel: semaphore: semaphore: Set test case to 1cpu
The test_sem_take_timeout_isr depends on the thread's priority. But for
SMP platforms, the priority is different with no-SMP. High-priority
threads and low-priority threads might run simultaneously at different
cores. Set the test case run at 1cpu to fix such an issue.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2023-09-22 09:25:12 +02:00
Jaxson Han 64086d04d5 tests: kernel: threads: dynamic_thread: increase the heap size
The heap size is not enough so that it will cause the testcase fail.
Increase to 32k to make sure it works for a long time in the future.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2023-09-22 09:25:12 +02:00
Gerard Marull-Paretas 3ff5222a6f tests: kernel: device: drop APPLICATION level
Level is about to be removed, so stop testing it.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-21 15:02:45 +02:00
TaiJu Wu fe5c915a56 test: fix ITRERATION_COUNT typo
ITERATION_COUNT was written as ITRERATION_COUNT.

Signed-off-by: TaiJu Wu <tjwu1217@gmail.com>
2023-09-19 09:53:03 -04:00
Anas Nashif a04a1d8991 tracing: remove references to deprecated k_pipe_block_put
k_pipe_block_put was deprecated some time ago.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-09-18 19:20:02 -04:00
Alberto Escolar Piedras 5dfc93b73c tests interrupt_offload: Set a proper interrupt for POSIX arch targets
The test assumed that interrupt line 5 was up for grabs, but it
is not in general. (For ex., on an nrf53_bsim this is the clock
interrupt, which cannot be hijacked).

Instead, for boards that define it, let's use the int line
used for offloading SW interrupts (which is defined for all posix
arch boards in tree)
And if this is not defined, let's skip the test.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-18 10:42:25 +01:00
Manuel Argüelles 738b124281 tests: kernel: usage: skip for mr_canhubk3 board
The mr_canhubk3 board enables by default an off-chip watchdog that must
be serviced to avoid triggering a reset and cannot be disabled on a
per-test basis.

test_all_stats_usage assumes the CPU was never idle before the test
starts but this is not the case for mr_canhubk3 because the off-chip
watchdog driver has a thread kicked off during device init that will
conflict with the expected usage stats on this test. So skip this test
for this board.

Signed-off-by: Manuel Argüelles <manuel.arguelles@nxp.com>
2023-09-18 10:37:22 +01:00
Anas Nashif ceb42a688e kernel: remove reference to non existing z_thread_heap_assign
we have no z_thread_heap_assign, was suppoosed to reference
k_thread_heap_assign.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-09-17 07:59:30 -04:00
Peter Mitsis c7255cf374 kernel: Remove references to _EXPIRED
The _EXPIRED macro is no longer necessary. It is a relic of an older
timeout processing algorithm from several years ago.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-09-15 19:16:20 -04:00
Carlo Caione e4a125b6a4 dt: Make zephyr,memory-attr a capabilities bitmask
This is the final step in making the `zephyr,memory-attr` property
actually useful.

The problem with the current implementation is that `zephyr,memory-attr`
is an enum type, this is making very difficult to use that to actually
describe the memory capabilities. The solution proposed in this PR is to
use the `zephyr,memory-attr` property as an OR-ed bitmask of memory
attributes.

With the change proposed in this PR it is possible in the DeviceTree to
mark the memory regions with a bitmask of attributes by using the
`zephyr,memory-attr` property. This property and the related memory
region can then be retrieved at run-time by leveraging a provided helper
library or the usual DT helpers.

The set of general attributes that can be specified in the property are
defined and explained in
`include/zephyr/dt-bindings/memory-attr/memory-attr.h` (the list can be
extended when needed).

For example, to mark a memory region in the DeviceTree as volatile,
non-cacheable, out-of-order:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_VOLATILE |
			       DT_MEM_NON_CACHEABLE |
			       DT_MEM_OOO )>;
   };

The `zephyr,memory-attr` property can also be used to set
architecture-specific custom attributes that can be interpreted at run
time. This is leveraged, among other things, to create MPU regions out
of DeviceTree defined memory regions on ARM, for example:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-region = "NOCACHE_REGION";
       zephyr,memory-attr = <( DT_ARM_MPU(ATTR_MPU_RAM_NOCACHE) )>;
   };

See `include/zephyr/dt-bindings/memory-attr/memory-attr-mpu.h` to see
how an architecture can define its own special memory attributes (in
this case ARM MPU).

The property can also be used to set custom software-specific
attributes. For example we can think of marking a memory region as
available to be used for memory allocation (not yet implemented):

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_NON_CACHEABLE |
			       DT_MEM_SW_ALLOCATABLE )>;
   };

Or maybe we can leverage the property to specify some alignment
requirements for the region:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_CACHEABLE |
			       DT_MEM_SW_ALIGN(32) )>;
   };

The conventional and recommended way to deal and manage with memory
regions marked with attributes is by using the provided `mem-attr`
helper library by enabling `CONFIG_MEM_ATTR` (or by using the usual DT
helpers).

When this option is enabled the list of memory regions and their
attributes are compiled in a user-accessible array and a set of
functions is made available that can be used to query, probe and act on
regions and attributes, see `include/zephyr/mem_mgmt/mem_attr.h`

Note that the `zephyr,memory-attr` property is only a descriptive
property of the capabilities of the associated memory  region, but it
does not result in any actual setting for the memory to be set. The
user, code or subsystem willing to use this information to do some work
(for example creating an MPU region out of the property) must use either
the provided `mem-attr` library or the usual DeviceTree helpers to
perform the required work / setting.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-09-15 12:46:54 +02:00
Dmytro Firsov 40fe36669c tests: kernel: exclude xenvm from device tests
Zephyr device and device.pm tests uses device tree fragments applied
to main board device trees. For xenvm they have conflicting
address/size cells definition with board DT. It leads to CI and test
issues during build (xenvm has 0x2 cells, tests have 0x1).

Signed-off-by: Dmytro Firsov <dmytro_firsov@epam.com>
2023-09-15 11:15:00 +01:00
Daniel Leung 3441c70117 tests: mem_protect/mem_protect: reuse child thread and stack
This reuses the child_thread variable and child_stack acorss
test suites.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-09-15 09:26:26 +02:00
Daniel Leung 4bebb65491 tests: mem_protect/mem_protect: fix number of kobjects to test
In test_kobject_perm_error, there are 13 kobjects to test but
the loop only do 12. So amend the code to test all 13 kobjects.

Also remove the parameter of tid to child thread as the child
thread is not using it.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-09-15 09:26:26 +02:00
Gerard Marull-Paretas 691facc20f include: always use <> for Zephyr includes
Double quotes "" should only be used for local headers.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-14 13:49:58 +02:00
Laurentiu Mihalcea 127696383f tests: kernel: interrupt: Add testcase for shared interrupts
This commit introduces a new testcase for shared interrupts.

Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
2023-09-14 08:35:12 +02:00
Anas Nashif 8634c3b444 kernel: move wait_q.h header to be internal
This header does not expose any public APIs, so move it under
kernel/include and change files including it.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-09-12 12:55:36 -04:00
Alexander Razinkov 9ae9df8b6f kernel: spinlock: k_spin_is_locked introduction
Currently spinlock internals are directly accessed from the tests.
This way the test becomes bound to the particular spinlock implementation.
To remove this unnecessary dependency the distinct API to check if spinlock
is locked is introduced.

k_spin_is_locked should be used for the spinlock testing only,
so the scope of this API is intentionally restricted.

Signed-off-by: Alexander Razinkov <alexander.razinkov@syntacore.com>
2023-09-07 14:26:55 +02:00
Keith Packard 844c78cf3a tests/kernel: Also run tests using minimallibc
With picolibc being the default C library, we need to explicitly include
testing against the minimal C library for kernel components.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-09-04 15:29:13 -04:00
Carles Cufi 8c748fd005 kernel: Modify the signature of k_mem_slab_free()
Modify the signature of the k_mem_slab_free() function with a new one,
replacing the old void **mem with void *mem as a parameter.

The following function:
void k_mem_slab_free(struct k_mem_slab *slab, void **mem);

has the wrong signature. mem is only used as a regular pointer, so there
is no need to use a double-pointer. The correct signature should be:
void k_mem_slab_free(struct k_mem_slab *slab, void *mem);

The issue with the current signature, although functional, is that it is
extremely confusing. I myself, a veteran Zephyr developer, was confused
by this parameter when looking at it recently.

All in-tree uses of the function have been adapted.

Fixes #61888.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-09-03 18:20:59 -04:00
Fabio Baltieri a15e7d2326 tests: work_queue: fix few mismatched CONTAINER_OF
Fix few mismatched CONTAINER_OF, going from struct k_work to struct
triggered_test_item should pass by struct k_work_poll.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-29 20:06:23 -04:00
Fabio Baltieri ec71be5d9d drivers,subsys: fix few missing k_work_delayable_from_work
Fix few instances of delayable work handlers using the k_work pointer
directly in a CONTAINER_OF pointing to a k_work_delayable.

This is harmless since the k_work is the first element in
k_work_delayable, but using k_work_delayable_from_work is the right way
of handling it.

Change a couple of explicit CONTAINER_OF doing the same work as the
macro in the process.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-28 10:12:21 +02:00
Alberto Escolar Piedras 9eeb78d86d COVERAGE: Fix COVERAGE_GCOV dependencies
CONFIG_COVERAGE has been incorrectly used to
change other kconfig options (stack sizes, etc)
code defaults, as well as some samples behaviour,
which should not have dependend on it.

Instead those should have depended on COVERAGE_GCOV,
which, being the one which adds special code and
temporary RAM storage for embedded targets,
require changes to many features.

When building for the native targets, all this was
unnecessary.

=> Fix the dependency.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-08-24 15:36:31 +02:00
Gerard Marull-Paretas 9c961571a2 modules: cmsis: move glue code to modules/cmsis
The CMSIS module glue code was part of arch/ directory. Move it to
modules/cmsis, and provide a single entry point for it: cmsis_core.h.
This entry header will include the right CMSIS header (M or A/R).

To make this change possible, CMSIS module Kconfig/CMake are declared as
external, allowing us to add a new Zephyr include directory.

All files including CMSIS have been updated.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-08-24 13:20:21 +02:00
Keith Packard 8a86733cfd tests/kernel/interrupt: Enable 'icount' for qemu_cortex_m0
This test fails when icount is disabled, so enable it

See 7bdc621ba9 which disabled icount by
default for this platform.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-08-23 10:09:44 +01:00
Jaxson Han d1a3b2631c tests: kernel: mem_protect: Increase stack size for 64BIT plat
Some 64 bit platforms do not have MMU, however the 64 bit platfoms need
a larger stack. This testcase fails with non-MMU 64 bit platform e.g.
v8r64 platform due to the stack overflow. To fix this issue, set 2k
stack for all 64 bit platforms (CONFIG_64BIT) as this is likely a common
issue for all non-MMU 64 bit platforms.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2023-08-21 13:27:07 +02:00
Jaxson Han fb7f7fcbc4 tests: kernel: threads: Slightly increase the heap pool size
The heap size is set to 20000 which is just not enough for v8r platform.
Fix testcases failure in tests/kernel/threads/ by increasing the heap
size to 21504.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2023-08-21 13:27:07 +02:00
Ryan McClelland 9ce16f8465 tests: kernel: fpu_sharing: fix double-promotions
Double promotion warnings are generated with the flag -Wdouble-promotion

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2023-08-18 12:06:31 +02:00
Manuel Argüelles 5d3d4eb8b0 tests: syscalls: add faulty address for s32z270dc2_r52 boards
Default faulty address does not generate the expected fault on the
s32z270dc2_r52 boards.

Signed-off-by: Manuel Argüelles <manuel.arguelles@nxp.com>
2023-08-16 15:04:14 +02:00
Johan Hedberg 03905f7e55 boards: x86: Add intel_ prefix to Elkhart Lake boards
This follows the same convention that has already been adopted by Intel
Alder Lake and Raptor Lake boards.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2023-08-15 11:24:35 +00:00
Evgeniy Paltsev a260d5b6bb ARC: tests: re-enable cpu_idle test for SMP nSIM platforms
The original issue is fixed some time ago, so re-enable the
test.

This reverts commit 52992b0658
("tests: skip the cpu_idle test for nsim_hs_smp")

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-08-11 12:01:01 +00:00
Joshua Lilly cce530cae4 scripts: build: gen_isr_tables: make bit masks configurable
Some architectures such as RISC-v support more than 255 interrupts
per aggrigator. This diff adds the ability to forgo the aggrigator
pattern and use a configurable number of bits for multilevel
interruts.

Signed-off-by: Joshua Lilly <jgl@meta.com>
2023-08-10 10:55:41 -04:00
Daniel Leung 174caf0c10 tests: kernel: renames shadow variables
Renames	shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:12 +00:00
Flavio Ceolin 2bb6ad76ec tests: stackprot: New test to check canaries behavior
Adding a new simple test that checks that canaries values
are different between threads when CONFIG_STACK_CANARIES_TLS
is enabled.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-08-08 19:08:04 -04:00
Flavio Ceolin 0f2d0ca40d tests: stackprot: Test canaries in TLS
Add a new test to enable stack canaries in TLS.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-08-08 19:08:04 -04:00
Seppo Takalo 4aeb80b374 kernel/timeout: Introduce comparison for timepoint values
Introduce new API to compare two timepoint values to
find the one that is going to expire sooner, or is already
expired.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-04 10:41:15 +02:00
Jaxson Han 81ca50900d tests: kernel: spinlock: Fix test_trylock thread reusable issue
The test_trylock reuses the cpu1_thread, but there is no way for it to
exit. This will cause the thread created twice, as a result, two cpu
running the same thread simultaneously cause an unexpected crash.

Fix this by adding initialization of resources and also the exit for the
cpu1_thread.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2023-08-02 16:34:04 +02:00
Carlo Caione b7e252c2db shared_multi_heap: Use proper enum instead of int
We have an enum for the memory attr, use that instead of a generic
unsigned int.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-07-26 07:56:39 -04:00
Jordan Yates 96138d233f tests: kernel: device: test sub-priority
Add tests for sorting devices at the same init priority based on their
devicetree ordinals.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-25 15:58:06 +00:00
Jordan Yates 3c1149e058 Revert "tests: kernel: device: test sub-priority"
This reverts commit 01e98fcb5f.
2023-07-25 14:17:11 +02:00
Carlo Caione 15e84cbfac dts: Move to 'zephyr,memory-attr'
Move to 'zephyr,memory-attr' and use the newly introduced helpers.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-07-25 11:22:10 +02:00
Jordan Yates 01e98fcb5f tests: kernel: device: test sub-priority
Add tests for sorting devices at the same init priority based on their
devicetree ordinals.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-25 09:13:16 +02:00
Nicolas Pitre 3c9249cedc tests: test the timepoint API
This tests sys_timepoint_calc(), sys_timepoint_timeout() and
sys_timepoint_expired().

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-07-25 09:12:26 +02:00
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