Commit graph

2595 commits

Author SHA1 Message Date
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
Andrei Emeltchenko 9ea701e930 tests: threads: Remove unused variable
Clean up dead code.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-30 12:37:14 -05:00
Keith Packard 394a0485fb tests/kernel/common: Let picolibc pick a malloc heap size
Now that picolibc's malloc arena configuration always allocates
some space, we don't need explicit allocations for tests.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-30 10:33:24 +02:00
Keith Packard 2263708c73 tests/mem_protect: Increase MPU sizes for qemu_cortex_a53
When running with picolibc, we need more MPU resources for these
tests. Get rid of picolibc malloc arena too.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-30 10:33:24 +02:00
Anas Nashif dba3d31ddd tests: kernel: common: increase timeout
Some platforms need more time when under load, 60s are not enough.

Seen on hifive_unleashed.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-06-29 17:00:21 -04:00
Anas Nashif ab24be5552 drivers: timer: provide timer irq to tests
As with previous commit, make the timer irq a simple integer variable
exported by the timer driver for the benefit of this one test
(tests/kernel/context).

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-06-29 10:31:00 +02:00
Andy Ross fb3b434438 drivers: timer: update TIMER_IRQ for tests/kernel/context
This test has gotten out of control.  It has a giant #if cascade
enumerating every timer driver in the Zephyr tree and extracting its
interrupt number.  Which means that every driver needs to somehow
expose that interrupt in its platform headers or some other API.

Make it a simple integer variable exported by the timer driver for the
benefit of this one test.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-06-29 10:31:00 +02:00
Daniel Leung 883c2483e9 tests: workq: remove tests using legacy work queue API
This is in preparation to remove the deprecated work queue
API.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-27 12:46:21 +02:00
Daniel Leung cfee0cbe2f tests: work_queue: update to use new k_work API
Update tests/kernel/workq/work_queue to use the new k_work_*
work queue API.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-27 12:46:21 +02:00
Keith Packard 88ca3aca98 tests/kernel: Provide expected output for picolibc in printk test
Picolibc has subtly different output from the minimal libc as a result
of different handling for code built without real long long support.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-24 20:30:03 +02:00
Keith Packard f79eaba7e6 tests/kernel: Run common tests using picolibc
This runs the existing kernel common tests using picolibc as some of those
depend on libc functionality.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-23 09:16:32 +02:00
Chen Peng1 bae794e300 test: interrupt: change the test interrupt line to a bigger one.
change the test interrupt line number to a bigger one, because
the low number usually will be used by other devices.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-06-23 09:08:43 +02:00
Yinfang Wang 540ab5eb4c tests: sched: preempt: Fix the skipped testing when enabling SMP
When SMP feature is enabled on board, this test suite will skip.
Enable the test suite by removing the filter.
Note that these testings only run SMP platform on single core
which are handled by setting MP_NUM_CPUS=1 in prj.conf.

Signed-off-by: Yinfang Wang <yinfang.wang@intel.com>
2022-06-22 12:22:01 +02:00
Stephanos Ioannidis 2e19e914bb tests: kernel: schedule_api: Migrate to K_THREAD_STACK_ARRAY_DECLARE
This commit updates all deprecated `K_THREAD_STACK_ARRAY_EXTERN` macro
usages to use the `K_THREAD_STACK_ARRAY_DECLARE` macro instead.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-20 10:25:52 +02:00
Stephanos Ioannidis d6de29cd97 tests: kernel: thread_apis: Migrate to K_THREAD_STACK_DECLARE
This commit updates all deprecated `K_THREAD_STACK_EXTERN` macro usages
to use the `K_THREAD_STACK_DECLARE` macro instead.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-20 10:25:52 +02:00
Stephanos Ioannidis 0b0d21efe7 tests: kernel: schedule_api: Migrate to K_THREAD_STACK_DECLARE
This commit updates all deprecated `K_THREAD_STACK_EXTERN` macro usages
to use the `K_THREAD_STACK_DECLARE` macro instead.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-20 10:25:52 +02:00
Stephanos Ioannidis ff0471a59b tests: kernel: msgq_api: Migrate to K_THREAD_STACK_DECLARE
This commit updates all deprecated `K_THREAD_STACK_EXTERN` macro usages
to use the `K_THREAD_STACK_DECLARE` macro instead.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-20 10:25:52 +02:00
Anas Nashif 64af112d30 tests: condition variables: move to new ztest API
Move test to new ztest API.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-06-18 08:10:32 -04:00
Stephanos Ioannidis 2904b0020e tests: kernel: stack_random: Disable -Wdangling-pointer warning
This commit selectively disables the dangling pointer warning
(`-Wdangling-pointer`) for the compilation of the `alternate_thread`
function because it deliberately makes use of a dangling pointer in
order to test stack randomisation.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-17 10:18:26 +02:00
Carlo Caione b6a3d598f3 device_mmio: Introduce DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME
Currently the device MMIO APIs is only able to map single DT-defined
regions and also the _NAMED variant is assuming that each DT-defined
device has only one single region to map.

This is a limitation and a problem when in the DT are defined devices
with multiple regions that need to be mapped.

This patch is trying to overcome this limitation by introducing the
DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME macro that leveraged the 'reg-names'
DT property to map multiple regions defined by a single device.

So for example in the DT we can have a device like:

  driver@c4000000 {
    reg = <0xc4000000 0x1000>, <0xc4001000 0x1000>;
    reg-names = "region0", "region1";
  };

and then we can use DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME doing:

  struct driver_config config = {
    DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME(region0, DT_DRV_INST(0)),
    DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME(region1, DT_DRV_INST(0)),
  };

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-16 11:26:10 +02:00
Nicolas Pitre f00573555b Z_POW2_CEIL: simplify implementation
Avoid potentially calling __builtin_clz() twice with non-constant
values. Also add a test for it.

Clang produces false positive vla warnings so disable them. GCC will
spot real vla's already.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-06-16 10:28:15 +02:00
Gerard Marull-Paretas 74ed64139c tests: remove redundant <zephyr/zephyr.h> includes
Files including <zephyr/kernel.h> do not have to include
<zephyr/zephyr.h>, a shim to <zephyr/kernel.h>.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-15 09:13:11 +02:00
Filip Kokosinski 06615c148d tests/kernel/usage/thread_runtime_stats: relax precision test for RISC-V
This commit relaxes the precision requirements for idle event statistic
test when RISC-V machine timer driver is used. This is needed for some
platforms (e.g. hifive1), for which the cycle count is too low to pass
the checks where a percent deviation of peak cycles count is allowed.

Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
2022-06-13 13:21:16 -04:00
Keith Packard 5d6b43f684 tests/timer_api: Use correct 'abs' macro with correct type parameter
Subtracting with a uint64_t operand yields a uint64_t result, for which
the absolute value is not terribly interesting. Cast the operand to
int64_t.

Use llabs instead of abs as abs takes an int parameter and not an
int64_t. This appears to work even with the minimal C library.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-14 01:50:36 +09:00
Daniel Leung a9972f3d99 tests: mem_protect/mem_map: enable userspace on qemu_x86_tiny
Due to qemu_x86_tiny having very small defined SRAM area,
enabling userspace results in not having enough free physical
pages to run the tests. So make the memory a bit larger so
we can actually test memory mapping with userspace.

Fixes #46398

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-13 12:12:42 +02:00
Hu Zhenyu 001cae0a5a test: Increase the tolerance between A3/A5
As the type of A(n) is integer, and A3 and A5 are close to
each other. Sometimes A3 is equal to A5. So change the ">" to
">="

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-06-10 07:08:49 -04:00
Carlo Caione 63fa264c22 tests: mem_protect/mem_map: qemu_x86_tiny: Exclude userspace testing
There are no enough free pages to run the test with userspace enabled on
qemu_x86_tiny. Disable it.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-10 09:48:23 +02:00
Carlo Caione f094542d64 tests: mem_protect/mem_map: Test also K_MEM_PERM_USER
The tests is currently testing all the memory mapping parameters but
K_MEM_PERM_USER. Add a test case to test that as well.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-10 09:48:23 +02:00
Yinfang Wang 3f69745784 tests: timer_monotonic: Enable APIC timer's TSC deadline mode on ehl_crb
ehl_crb supports HPET timer by default. Add test suite to test APIC
timer's TSC deadline mode on ehl_crb.

Signed-off-by: Yinfang Wang <yinfang.wang@intel.com>
2022-06-06 22:45:58 +02:00
Gerard Marull-Paretas 6cfdd336dd tests: kernel: context: fix soc.h include policy
Include only on platforms that are known to require it.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-05 14:48:40 +02:00
Keith Packard d24e975a71 tests/kernel/common: Include errno_private.h
This ensures that we have a definition of z_errno in case
that isn't pulled in with errno.h

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-05-27 15:34:34 -07:00
Yinfang Wang e19fd4d3fa tests: fpu_sharing: Fix the skipped testing on acrn_ehl_crb
acrn_ehl_crb itself supports fpu_sharing.
Enable the fpu_sharing testing on acrn_ehl_crb.

Signed-off-by: Yinfang Wang <yinfang.wang@intel.com>
2022-05-20 19:24:54 -07:00
Ruibin Chang bc2f83f11c tests/kernel/sched/schedule_api: don't break the test if not divisible
When test tests/kernel/sched/schedule_api, it shows "ASSERTION FAIL:
timeslice in ticks much be divisible by two", then break and fail
the test.

Fixes #44887.

On board it8xxx2_evb, it can pass schedule_api test without
the assertion, so I add the floating part back to half_slice_cyc
when the timeslice in ticks can't be divisible by two.
After change, the time slice will be:
1.slice_ticks = (200x8192+999)/1000 = 1639 (not changed)
2.before add the deviation (not handle the floating part):
half_slice_cyc = (1639/2) * (32768/8192) = (819) * (32768/8192) = 3276,
after add the deviation:
half_slice_cyc = 3276 + (32768/8192/2) = 3278,
and it's equal (1639/2) * (32768/8192) = 3278.

Verified by test pattern:
west build -p always -b it8xxx2_evb tests/kernel/sched/schedule_api

Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2022-05-20 19:23:45 -07:00
Andy Ross 4b9a8a8471 tests/kernel/common: Extend nested_irq_offload case to do a context switch
Bug #45779 discovered an edge case with nested interrupts on Xtensa
where they might select an incorrect thread context to return to
instead of the (mandatory!) return to the outer interrupt context.

Cleverly adjust the nested_irq_offload to exercise this.  It now
creates a thread that it knows it will interrupt, then suspends that
thread from within the inner/nested interrupt.  This guarantees that
_current will be different on exit from the second interrupt, which is
the case that tripped up Xtensa.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-05-20 12:37:59 +02:00
Krzysztof Chruscinski 2a2856e88e tests: kernel: workq: work: Fix potential race in the test
Test was setting up timer for 1 system tick and then work was
cancelled. It was assumed that work will be cancelled before
timer expires. This is the case for low frequency system clock
(e.g. qemu targets using 100Hz) but there are cases when system
clock has higher frequency (32kHz on nRF). In that case, timer
was occasionally expiring before cancellation and test was
randomly failing.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-05-20 12:37:18 +02:00
Andy Ross c64ac967a8 tests/kernel/fatal: Work around historical API misuse
This test was written to do a k_oops() in the main thread.  That's an
essential thread, and aborting it is actually a system panic now.  The
test was written contra the docs on this, but it worked fine for
years.

Just reflag the thread as a simple workaround rather than trying
anything fancy. This is a very simple test.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-05-20 12:34:30 +02:00
Andy Ross fb613594c7 kernel/sched: Panic on aborting essential threads
Documentation specifies that aborting/terminating/exiting essential
threads is a system panic condition, but we didn't actually implement
that and allowed it as for other threads. At least one app wants to
exploit this documented behavior as a "watchdog" kind of condition,
and that seems reasonable.  Do what we say we're supposed to do.

This also includes a small fix to a test, which seemed like it was
written to exercise exactly this condition.  Except that it failed to
detect whether or not a system fatal error was actually signaled and
was (incorrectly) indicating "success".  Check that we actually enter
the handler.

Fixes #45545

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-05-20 12:34:30 +02:00
Nicolas Pitre 92409f36de riscv: drop user stack guard area when using separate privileged stacks
A separate privileged stack is used when CONFIG_GEN_PRIV_STACKS=y. The
main stack guard area is no longer needed and can be made available to
the application upon transitioning to user mode. And that's actually
required if we want a naturally aligned power-of-two buffer to let the
PMP map a NAPOT entry on it which is the whole point of having this
CONFIG_PMP_POWER_OF_TWO_ALIGNMENT option in the first place.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-05-18 10:54:53 +02:00
Nicolas Pitre 6051ea7d3c riscv: clarify stack size and alignment parameters
The StackGuard area is used to save the esf and run the exception code
resulting from a StackGuard trap. Size it appropriately.

Remove redundancy, clarify documentation, etc.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-05-18 10:54:53 +02:00
Guo Lixin 80b2d7722d tests: add filter of configs to avoid mismatch test running
Some test suites have different test case lists in test_main(), that
conforms to different test scenarios defined in testcase.yaml. We
use if statement to decide which test case list should run under
specific config.
But for thoses boards who do not support those configs, we will run test
cases on the other side of the if statement even if it has deviated from
the original test scenario.
So add filter to avoid test scenario running under mismatch config.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-05-16 22:49:34 -04:00
Huifeng Zhang 265080277c tests: kernel: semaphore: fix mutual exclusion test issue
Mutual exclusion test assume that the excution order of two threads like
this:
    mutual_exclusion1 -> mutual_exclusion2 -> mutual_exclusion1 ...

but some times the excution order of two threads would be this:
    mutual_exclusion1 -> mutual_exclusion2 -> mutual_exclusion2 ...

This patch increase the loop cycle, add a variable 'tmp' to store the
value of 'critical_var' before operating it.

Signed-off-by: Huifeng Zhang <Huifeng.Zhang@arm.com>
2022-05-17 11:45:16 +09:00
Jaxson Han 74d61fe744 tests: kernel: semaphore: sys_sem: Fix coherence issue
The issue is caused by multiple threads which have taken the semaphore
to increase or decrease the normal count variable. Change its type with
atomic_t.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2022-05-17 11:45:16 +09:00
Yinfang Wang dffe3508dc tests: fpu_sharing: Fix the skipped testing on ehl_crb
ehl_crb itself supports fpu_sharing.
  Enable the fpu_sharing testing on ehl_crb.

Signed-off-by: Yinfang Wang <yinfang.wang@intel.com>
2022-05-16 22:42:49 -04:00
Stephanos Ioannidis b744130735 tests: timer_monotonic: Use volatile for timing variables
This commit adds the `volatile` qualifier to the timing variables, in
order to ensure that the compiler does not try to optimise the test in
a way that can affect the execution time measurements.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-16 09:43:52 -04:00
Anas Nashif 84410f57b2 tests: mem_protect: define testcases in yaml
Define all testcases in the yaml for consistency and issue parsing
them during setup.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif d61eb2bd47 tests: mutex: define testcases in yaml
Define testcases in yaml to workaround inconsistencies in parsing.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Peter Mitsis e83dde1628 tests: runtime threads stats
Adds tests to verify the gathering of thread runtime stats.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-05-13 10:19:53 -05:00
Lucas Dietrich 616efeb2f2 tests: workq: Add a regression test for issue #45267
When an object availability event triggers a k_work_poll
item, the object lock should not be held anymore
during the execution of the work callback.

Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
2022-05-10 18:39:51 +02:00
Gerard Marull-Paretas d342e4c4c1 linker: update files with <zephyr/...> include prefix
Linker files were not migrated with the new <zephyr/...> prefix.  Note
that the conversion has been scripted, refer to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-09 12:45:29 -04:00
Gerard Marull-Paretas ade7ccb918 tests: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all tests to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 20:02:14 +02:00
Jordan Yates 775030e6f1 tests: kernel: validate k_can_yield
Validate the behaviour of `k_can_yield` in pre-kernel, ISR, and idle
thread and standard thread contexts.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-05-06 11:33:10 +02:00
Bradley Bolen afef64e236 tests: fpu_sharing: Support FPU disable test for Cortex-A/R
For testing, assume that the Cortex-A/R platforms are using a GIC
interrupt controller.  Use the last GIC SGI to trigger an interrupt for
the test.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2022-05-05 12:03:27 +09:00
Bradley Bolen 90b1c6a3e8 tests: fpu_sharing: Enable support for Cortex-R
Reuse the Cortex-M paths for testing the floating point unit.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2022-05-05 12:03:27 +09:00
Nicolas Pitre 2fece49a14 riscv: pmp: switch over to the new implementation
Add the appropriate hooks effectively replacing the old implementation
with the new one.

Also the stackguard wasn't properly enforced especially with the
usermode combination. This is now fixed.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-04-29 15:30:00 +02:00
Keith Packard 6f9f8c1e32 samples, tests: Add z_libc_partition to all test domains
When a memory domain is initialized, the z_libc_partition must be
included so that critical libc-related data can be accessed.

On ARM processors without TPIDRURO when THREAD_LOCAL_STORAGE is enabled,
this includes the TLS base pointer, which is used for several
thread-local variables in the kernel.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-04-28 11:09:01 +09:00
Keith Packard 19c8956946 tests: Disable HW stack protection for some mpu tests
When active, z_libc_partition consumes an MPU region which leaves too
few for some MPU tests. Free up one by disabling HW stack protection.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-04-28 11:09:01 +09:00
Keith Packard b03b2e0403 tests/kernel/mem_protect: Check for thread_userspace_local_data
When using THREAD_LOCAL_STORAGE the thread_userspace_local_data stuff
isn't used, so these tests wouldn't build.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-04-28 11:09:01 +09:00
Guo Lixin 8b2f5f0965 tests: Increase timeout for some tests
There are tests failing due to timeout for a few seconds in simulators,
slightly increase the timeout for these cases.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-04-26 13:57:43 -04:00
Carlo Caione 82451951cf tests: Misc test fixes for fvp_base_revc_2xaemv8a
Fix several tests for the fvp_base_revc_2xaemv8a board.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-04-26 09:00:18 +02:00
Carlo Caione 1dcea253d2 shared_multi_heap: Rework framework
Entirely rework the shared_multi_heap framework. Refer to the
documentation for more information.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-04-21 13:15:26 +02:00
Peter Mitsis a30cf39975 kernel: update k_thread_state_str() API
When threads are in more than one state at a time, k_thread_state_str()
returns a string that lists each of its states delimited by a '+'.
This in turn necessitates a change to the API that includes both a
pointer to the buffer to use for the string and the size of the buffer.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-04-20 20:20:13 -04:00
Anas Nashif 26b28b9527 tests: thread_api: test k_thread_cpu_pin
add a few asserts to test the new API.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-19 13:05:09 -04:00
Stephanos Ioannidis b48fc1d0f2 tests: kernel: timer_monotonic: Exclude for qemu_arc_hs
This commit excludes the kernel monotonic timer test for the
`qemu_arc_hs` platform because this test may fail with the ARC QEMU
6.2 on certain host systems.

Refer to the following issues for more details:

* foss-for-synopsys-dwc-arc-processors/qemu#67
* zephyrproject-rtos/zephyr#44862

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-04-19 09:15:06 -04:00
Stephanos Ioannidis 97064045d2 tests: kernel: syscall: Exclude for qemu_arc_em
This commit excludes the kernel syscall test for the `qemu_arc_em`
platform because this test may fail with the ARC QEMU 6.2 on certain
host systems.

Refer to the following issues for more details:

* foss-for-synopsys-dwc-arc-processors/qemu#66
* zephyrproject-rtos/zephyr#44862

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-04-19 09:15:06 -04:00
Gerard Marull-Paretas c925b5991a include: remove unnecessary autoconf.h includes
The autoconf.h header is not required because the definitions present in
the file are exposed using the compiler `-imacros` flag.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-05 11:18:20 +02:00
Katarzyna Giadla 681e3a16c7 tests: Change duplicated names of the test cases
Some names of the test cases are duplicated within the project.
This commit contains the proposed names of the test scenarios.

Signed-off-by: Katarzyna Giadla <katarzyna.giadla@nordicsemi.no>
2022-03-30 17:42:01 -04:00
Nazar Kazakov f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Flavio Ceolin 97116a5a84 tests: Increase timeout for some tests
There are tests failing sometimes due timeouts in simulators, slightly
increase the default timeout for these cases.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-03-17 17:31:00 -04:00
Sylvio Alves ddf88c6b99 tests: kernel: context: add esp32c3 irq value
Allow esp32c3 soc to proper execute this kernel test.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2022-03-17 11:33:36 +01:00
Gerard Marull-Paretas 22fe2142f0 pm: policy: use DEFAULT/CUSTOM naming
The residency policy, is in reality, influences by other parameters for
example constraints. It has been renamed to "DEFAULT" policy to make it
more general. The "APP" policy has been renamed to "CUSTOM" to better
represent its purpose.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-16 15:26:47 +01:00
Nicolas Pitre 4f417940ca tests: dynamic_thread: no need to exclude x86 anymore
The heap allocator does honor alignment needs now.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-03-14 19:18:34 -04:00
Nicolas Pitre 6d4e3dd611 tests: dynamic_thread: fix test_thread_index_management
This test was working by accident onarm64 and riscv64. Those
architectures have large register files, even more so considering
their 64-bit nature.

This test works by calling k_object_alloc(K_OBJ_THREAD) until thread
index exhaustion. However here it exhausted heap memory before running
out of thread indexes. There was a test to make sure that wasn't the
case by attempting a k_malloc(256). But here that succeeded just
because 256 is far smaller than a struct k_thread on the above
architectures.

Fix this by:

- attempting an additional allocation with the actual object size
  instead of an arbitrary 256 bites
- increasing the heap size as 8192 was clearly insufficient for the
  above platforms.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-03-14 19:18:34 -04:00
Marcin Szkudlinski 2a0ee8c920 lib/os: Add metadata to heap in multi_heap
When operating on different kinds of heaps sometimes there's a need to
perform special operations on heap, poweroff memory bank when releasing
memory etc. Therefore some additional data may be required.
Metadata is a point to keep such data.

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
2022-03-11 13:56:05 -05:00
Andy Ross 672d0962c0 tests/kernel/schedule_api: Add TIMESLICE_PER_THREAD case
Simple coverage exerciser for the per-thread timeslice feature.  Added
as a(nother) new variant of the schedule_api test.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-03-09 13:49:44 -05:00
Ederson de Souza ab17f69a72 tests/kernel/fpu_sharing: Run test with MP_NUM_CPUS=1
This test uses k_yield() to "sync" between threads, so it's implicitly
supposed to run on a single CPU. Make it explicit, to avoid issues on
platforms with more cores.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>

FIXKFLOATDISABLE
2022-02-25 19:13:50 -05:00
Daniel Leung 45940cf8cf tests: kernel/common: fix inadequate failing to thread context
The thread context test has insufficient checkings for failing
so add them:

() The variable rv for pass/fail is set but never checked. So
   add a check to fail the test if such indicated.
() Each thread's pass variable is set to TC_FAIL (== 1) and
   the check for successful thread execution simply checks
   if pass variable is not zero, which is always true. So
   change it so the check for failing condition is reasonable.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-02-24 08:38:38 -06:00
Bradley Bolen c0dd594d4d arch: arm: aarch32: Change CPU_CORTEX_R kconfig option
Change the CPU_CORTEX_R kconfig option to CPU_AARCH32_CORTEX_R to
distinguish the armv7 version from the armv8 version of Cortex-R.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2022-02-23 08:14:15 -06:00
Anas Nashif f0676d960b tests: condvar: fix priorities to make tests run
Fix priorities for the test threads to allow execution when test thread
yields.
Also cleanup some strings.

Fixes #42723

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-02-22 13:10:26 -05:00
Carles Cufi e83a13aabf kconfig: Rename the TEST_EXTRA stack size option to align with the rest
All stack sizes should end with STACK_SIZE.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-22 08:23:05 -05:00
Carles Cufi 4b8f1c04ab kconfig: Rename the ZTEST stack size option to align with the rest
All stack sizes should end with STACK_SIZE.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-22 08:23:05 -05:00
Chen Peng1 b3c4b90a21 tests: skip kernel_timer_interrupts when CONFIG_TICKLESS_KERNEL=n.
Skip kernel_timer_interrupts when CONFIG_TICKLESS_KERNEL
is disabled, because timer won't generate interrupts
anymore after invoking irq_disable and irq_enable
to enable timer interrupt again in TICK mode.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-02-21 22:13:54 -05:00
Andy Ross 59d5dc4dcf tests/kernel/common: Add nested irq_offload() test
Add a very simple test of the CONFIG_IRQ_OFFSET_NESTED feature that
exercises nested interrupts in a portable way.  It calls irq_offset()
from within a k_timer callback and validates that the return lands
back in the original interrupt successfully.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-02-21 22:10:03 -05:00
Anas Nashif 6e8383c6ed tests: message_capture: do not exclude intel_adsp_cavs15
No reason to exclude this platform, we only have been using wrong
logging defaults (which was set in the soc) and not printing log
messages which is required by the test.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-02-21 21:57:40 -05:00
Mahesh Mahadevan 7e4d8c9cd5 tests: skip arch_nop test for ARM platforms
ARM does not guarantee the timing effects of NOP
instruction. Hence skip the test_nop test.
Fix for Issue#42666

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2022-02-21 21:54:53 -05:00
David Leach fdea2a628b tests: mem_protect: ensure allocated objects are initialized
K_OBJ_MSGQ, K_OBJ_PIPE, and K_OBJ_STACK objects have pointers
to additional memory that can be allocated. The k_obj_alloc()
returns these objects as uninitialized so when they are freed
there are random opportunities for freeing invalid memory
and causing random faults.

Signed-off-by: David Leach <david.leach@nxp.com>
2022-02-21 20:43:47 -05:00
David Leach a0737e687c tests: mem_protect: avoid allocating K_OBJ_MSGQ in userspace.
The K_OBJ_MSGQ object is unitialized so when the thread cleanup occurs
after an expected fault for invalid access the test case can randomly
fault again because the cleanup of the thread will sometimes attempt
to free invalid buffer_start pointer in the msgq object.

Fixes #42705

Signed-off-by: David Leach <david.leach@nxp.com>
2022-02-21 20:43:47 -05:00
Nicolas Pitre a1ce2fb990 tests: lifo_usage: make it less susceptible to SMP races
On SMP, and especially using qemu on a busy system, it is possible for
a thread with a later timeout to get ahead of another one with an
earlier timeout. The tight timeout value difference (10ms) makes it
possible albeit difficult to reproduce. The result is something like:

|START - test_timeout_threads_pend_on_lifo
| thread (q order: 2, t/o: 0, lifo 0x4001d350)
|
|    Assertion failed at main.c:140:
|test_multiple_threads_pending: (data->timeout_order not equal to ii)
| *** thread 2 woke up, expected 1

Let's make timeout values 10 times larger to make this unlikely race
even less likely.

While at it... The timeout field in struct timeout_order_data is some ms
value and not a number of ticks, so change the type accordingly.
And leverage k_cyc_to_ms_floor32() to simplify computation in
is_timeout_in_range().

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-14 09:32:03 -05:00
Daniel Leung 771c177909 tests: k_heap_api: make alloc pending tests a bit more robust
Both alloc_pending tests requires the main thread to utilize
the heap so that child threads must pend on memory allocations.
However, the previous implementation was not SMP friendly where
the child threads could run and succeeded in memory allocation
on other CPUs while the main thread continued to allocate
memory. The main thread would fail to allocate memory if
the child thread (on other CPU) has not freed the memory yet.
Not to mention that, in this scenario, the child thread was not
pending on memory allocation which defeated the purpose of
the test. So to fix this, make sure the main thread allocates
enough memory so future allocations must go into pending.
Also, check that the child thread cannot allocation memory
when first entered so it is actually going into pending.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-02-08 07:34:48 -05:00
Andy Ross 4c1f1edf21 test/kernel/mbox: Drop needless _1cpu_ from test cases
This test is already running with CONFIG_MP_NUM_CPUS=1.  All those
1cpu declarations are needless.  And some of them (like the init
tests) have side effects that make it difficult to do things like
"filter for only MP cases".

(Indeed, this is a heavily MP-unsafe test; almost all cases written to
rely on ordering between a parent thread and its child.  And that's
doubly so for COHERENE platforms because lots and lots of the test
objects are on stacks.  MP_NUM_CPUS=1 is definitely the right thing
here.)

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-01-26 13:34:45 -05:00
Andy Ross 53c8d61529 tests/kernel/interrupt: Don't wait so long just for a tick
There's no reason to wait a whole second here just to know if a tick
should have fired (though, yes, on some older/legacy/non-tickless
configurations, 128 ticks is actually more than a second).

Some simulators are very slow; busy waiting is expensive.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-01-26 13:34:45 -05:00
Ederson de Souza 1b99804634 Revert "tests/kernel/obj_tracking: Filter cAVS 2.5 builds to prevent DSP host hangs"
This reverts commit ae8745df6f.

Patch "kernel/init.c: Initialise logging subsystem after arch" should
fix this, so no more need to filter this test out.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2022-01-26 10:09:19 -05:00
Daniel Leung 1e16feacda tests: semaphore: fix empty loop error for XCC
When building with XCC, k_therad_access_grant() expands to
a loop but does nothing if no building for userspace. XCC
does not like this and emits error:

  main.s: Assembler messages:
  main.s:4563: Error: invalid empty loop

So add #ifdef to only enable the loop if userspace is enabled.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-25 21:16:32 -05:00
Daniel Leung b6854d0cbc tests: condvar_api: fix empty loop error for XCC
When building with XCC, the for loop to call k_therad_access_grant()
is an empty loop because k_thread_access_grant() does nothing
if no building for userspace. XCC does not like this and emits
error:

  main.s: Assembler messages:
  main.s:1951: Error: invalid empty loop

So add #ifdef to only enable the loop if userspace is enabled.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-25 21:16:32 -05:00
Andy Ross ae8745df6f tests/kernel/obj_tracking: Filter cAVS 2.5 builds to prevent DSP host hangs
This test is triggering some kind of bug that will reliably cause a
full host crash/hang of the x86 host environment on TGL/cAVS 2.5.
It's interfering with CI testing, so filter it out for now while we
figure it out.

Interestingly it doesn't have any trouble on older cavs15.  And even
more so, it seems to be some kind of build interaction.  If I disable
LOG=y, it passes. But when it fails, it actually fails BEFORE the boot
entry and core 0 initialization code is reached (i.e. LONG before any
logging initialization).  Something is wrong with the generated file;
maybe a linker or rimage bug?  The signature is reported OK by the
ROM, but that's the last we hear from the device before it blows up.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-01-21 13:22:15 -05:00
Andy Ross 64bdc044c4 tests/kernel/queue: Mark SMP-unsafe case 1cpu, reduce logging output
The test_queue_multithread_competition case wants to be sure that an
inserted item is recevied by the highest priority thread of several
waiting, but that only works if the threads aren't racing against each
other on different CPUs.

Also, the test_queue_loop case would produce a LOT of console output
very quickly.  On a few occasions, I saw this overflow the 8k output
buffer of the intel_adsp devices at exactly the wrong time (with
respect to the polling loop in the host python script), cause a flush
of the stream, and then miss the SUCCESSFUL message.  Quiet things
down a bit, there's not a lot of value of verbosity in a CI test.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-01-21 13:22:15 -05:00
Andy Ross 6f8bb5d9fe tests/kernel/semaphore: Skip COHERENCE-hostile test cases
These two cases use a k_pipe to transfer data, and do it (as is
customary) by copying into or out of buffers on the stack.  But that
doesn't work when KERNEL_COHERENCE=y, because the pipe code has a
possibly-too-sophisticated zero copy implementation, and will do the
copy into the destination thread synchronously with the k_put_put()
call from the other CPU.

Normally the fix is to use a static buffer instead, but in this case
the buffers are shared between multiple simultaneous threads, so can't
be shared.

Just skip the tests, pending some rework to how they communicate.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-01-21 13:22:15 -05:00
Andy Ross 8fe7d9d6df tests/kernel/mp: Must enable KERNEL_COHERENCE explicitly
This is test assumes that shared static/global variables are coherent
between the CPUs.  That's true on incoherent platforms only when
CONFIG_KERNEL_COHERENCE=y.  Normally that gets turned on along with
SMP, but this is using the lower level mp API directly and didn't have
that.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-01-21 13:22:15 -05:00
Andy Ross 8d13be016a tests/kernel/fatal/exception: Remove legacy irq_lock() usage
The irq_lock() API is a legacy API not to be used for synchronization
by new code, and in any case is only being used in cargo-cult fashion
here.  These test cases all do synchronous exceptions, there's
literally nothing to synchronize against.

    (And in this case they're exposing a legacy wart.  On platforms where:

    1. SMP=y, which causes irq_lock() to be implemented as a somewhat
       complicated global lock

    2. No ARCH_EXCEPT() macro is defined, which causes the kernel to
       use a fallback that simply aborts the current thread.

    ...this test will then abort a thread holding the lock, which will
    cause it to be orphaned (if it weren't a legacy API, the kernel
    should probably attempt to clean it up in k_thread_abort(), but it
    is, and it doesn't), so the next attempt to lock it will hang.
    And it's even worse, because this test builds with SMP=y and
    MP_NUM_CPUS=1, so the hand will happen with interrupts masked on a
    system with only one CPU, and everything will lock up solid.)

Fixes #41877

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-01-19 15:10:55 -05:00
Antony Pavlov 3c6d749e49 tests: kernel: fatal: add MIPS exception comments
We don't use TLB at the moment. Jumping to address 0 (USEG)
leads to TLB exception (instruction fetch).

Division by zero leads to TRAP exception.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
2022-01-19 13:48:21 -05:00
Antony Pavlov 59c7507e1a tests: kernel: context: add MIPS support
This test requires explicit architecture support, which this commit
adds for MIPS.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
2022-01-19 13:48:21 -05:00
Daniel Leung 7dac931e36 tests: kernel/events/event_api: memory coherence fixes
When CONFIG_KERNEL_COHERENCE=y, the k_event struct objects
cannot be declared on stacks since they are incoherent among
CPUs in the system.

So mark them as static to place them in global data section
and thus are coherence between CPUs.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-18 20:26:42 -05:00
Andy Ross 4796037cf7 tests/kernel/queue: Coherence fixes for tests/kernel/queue
When CONFIG_KERNEL_COHERENCE=y, it's not legal to place shared data
(like the queue elements in this test case) on the stack, because that
memory is incoherent with respect to other CPUs in the system.

Make them static (another option would have been to mark the test case
1cpu).

Fixes #41860

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-01-18 19:18:09 -05:00
Enjia Mai e61e63e33f tests: interrupt: refine the interrupt testcases
This PR include 2 changes to refine the testcases:
1. Now we using IPI to trigger interrupt in testing instead of INT
   instruction, this means we don't need to hardcode the vector
   number. That can avoid some problem.

Fixes: #40374

2. Refined the test cases. Tigger interrupt by INT instruction and
   IPI cannot be masked by irq_disabled(). Unless it's a external
   interrupt, such as a timer. Now remove those incorrect part of
   these testcases.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2022-01-18 13:24:28 -05:00
Jim Shu e2d67d60ba tests: mem_protect: enlarge heap size of RISCV64
Because k_thread size in RISCV64 is near 512 bytes, (num_of_thread *
256) bytes heap size is not enough. Enlarge heap size in RISCV64
to the (num_of_thread * 1024) bytes like x86_64 and ARM64.

Signed-off-by: Jim Shu <cwshu09@gmail.com>
2022-01-18 13:11:36 -05:00
Carlo Caione 8edf9817c0 tests/kernel/smp: Add SMP switch torture test
Formalize and rework the issue reproducer for #40795 and add it to the
SMP test suite.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-01-18 12:05:54 -05:00
Daniel Leung 8113b59c02 tests: mslab_api: remove double asterisk inside func comments
Doxygen treats "/**" as documentation even if the comment block
is inside the function. So remove the extra asterisk for those
"TESTPOINT" comments.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Daniel Leung 8f7f62869a tests: remove @return doc for void functions
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Gerard Marull-Paretas 696caa0524 pm: policy: return a reference to the next state
Return a constant reference to the next state instead of a copy of
struct pm_state_info. When the next state should be active, just return
NULL. Struct copying should be in general avoided, specially in code
paths executed frequently as is this one.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-11 10:46:20 +01:00
Peter Mitsis 192265c661 tests: pipes: Add pipe flush tests
Extends the pipes tests to include tests for k_pipe_flush() and
k_pipe_buffer_flush().

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-01-10 12:17:14 -05:00
Lixin Guo 76a4c6dc72 tests: workq: add support for null name parameter
Validate k_work_queue_start() API with null name config, this should
not affect the name of queue's thread.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2022-01-10 11:03:01 -05:00
Lixin Guo b5b629a115 tests: work: add support for k_work_flush() API
Add test for flushing work items in order, see if it works
as expected.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2022-01-04 09:27:18 -05:00
Lixin Guo 874c893b03 tests: work: add support for k_work_queue_unplug API
Validate unplug a already unplugged queue, this should not
affect the status of queue and return expected value.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2022-01-04 09:27:18 -05:00
Lixin Guo ef7e01091e tests: work: add support for work_cancel_sync API
Add test for cancelling unqueued(idle) work items, this should not
affect the work item and return value as expected.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2022-01-04 09:27:18 -05:00
Daniel DeGrasse f6497e37da tests: kernel: Fix assumption in test_kernel_cpu_idle
test_kernel_cpu_idle assumes that CPU's next timer wakeup will be
1 millisecond in the future based on kernel timer it sets. Move tick
synchronization delay into test loop so this will always be the case.

Fixes #41347

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-01-04 09:13:57 -05:00
Lixin Guo 0ef5dac70e tests: workq: add support for k_work_queue_init()
According to documentation, the memory of struct: k_work_q should
be zeroed.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2021-12-24 20:47:03 -05:00
TOKITA Hiroshi da68cde759 tests: skip arch_nop test when machine timer uses divided sys clock
When the case machine timer clock uses the divided system clock,
k_cycle_get_32() can't measure accurately how many cycles elapsed.

For example, use the value as timer clock obtained by dividing
the system clock by 4.
In this case, measuring a duration with k_cycle_get32() has up to 3
(4-1) cycles systematic error.

To run this test, we need to insert an appropriate of nops
with consideration for the errors.
'nop' can not repeat with for loop.
Must insert as separated statement.
But we don't have a convenient function such as
BOOST_PP_REPEAT in C++.

At this time, Implementing a generic test is a bit difficult.
Skipping this test in the case.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2021-12-20 17:51:30 +01:00
Anas Nashif 05ecd46a84 tests: fix typos and misnamed platforms
Various obsolote and misnamed platfomrs in test filters theat went
undetected for a while.

Fixes #41222

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-12-17 12:24:37 -05:00
Ederson de Souza bdaac354f4 kernel: Bring back object tracking
When CONFIG_TRACING_OBJECT_TRACKING is enabled, the kernel will keep
lists of some objects (detailed below), so that debuggers or other tools
can keep track of them.

The lists of objects are:

struct k_timer *_track_list_k_timer;
struct k_mem_slab *_track_list_k_mem_slab;
struct k_sem *_track_list_k_sem;
struct k_mutex *_track_list_k_mutex;
struct k_stack *_track_list_k_stack;
struct k_msgq *_track_list_k_msgq;
struct k_mbox *_track_list_k_mbox;
struct k_pipe *_track_list_k_pipe;
struct k_queue *_track_list_k_queue;

Note that while CONFIG_TRACING is needed, one can always use
CONFIG_TRACE_NONE=y. Also, tracking will only be done for objects that
are also being traced (so, to prevent tracking of some type of object,
such as k_timer, just make CONFIG_TRACING_TIMER=n).

Some simple "sanity checking" tests are also added in this patch.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2021-12-14 07:42:31 -05:00
Lixin Guo d7bbfabfc3 tests: work: exclude hifive1 board
Exclude hifive1 board from tests/kernel/workq/work/kernel.work,
this board has a issue with this test suite and block all related
CI.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2021-12-14 07:41:41 -05:00
NingX Zhao 3419038bc1 tests: improve the testcases of queue
In test_queue_append_list_error function, try to append an unnormal
list to check if the data is successful to append, and improve the
coverage for queue.c

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2021-12-13 20:31:35 -05:00
Daniel DeGrasse 369a54514f tests: kernel: threads: Correct test assertion in thread_apis test
Thread APIs test for k_busy_wait incorrectly asserted that a delay of
100 us should produce a delay in cycles less than or equal to to 100 cycles
of the hardware clock. Since most hardware clocks are fast, this assertion
was valid, but it does not test for the actual delay.

Fix the assertion to verify that a delay of 100 us produces a delay in
cycles less than or equal to 100 us worth of hardware clock cycles.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2021-12-13 20:13:21 -05:00
Carles Cufi cfbaac6733 tests: kernel: Fix address-of-packed-mem warning
The warning below appears once -Waddress-of-packed-mem is enabled:

/__w/zephyr/zephyr/tests/kernel/mem_protect/userspace/src/main.c: In
function 'test_main':
/__w/zephyr/zephyr/tests/kernel/mem_protect/userspace/src/main.c:1024:17:
error: converting a packed 'k_thread_stack_t' {aka 'struct
z_thread_stack_element'} pointer (alignment 1) to a 'struct
z_x86_thread_stack_header' pointer (alignment 4096) may result in an
unaligned pointer value [-Werror=address-of-packed-member]
 1024 |  hdr = ((struct z_x86_thread_stack_header *)ztest_thread_stack);

To avoid the warning, use an intermediate void * variable.

More info in #16587.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-12-10 14:08:59 +01:00
Lixin Guo 51cd1fcde6 tests: syscall: fix low value of CONFIG_MAX_THREAD_BYTES
Failed to build tests/kernel/mem_protect/syscalls on fvp_baser_aemv8r_smp
because the default value of CONFIG_MAX_THREAD_BYTES is too low.
So manually set the value to 5 in test case's prj.conf file.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2021-12-09 19:46:25 -05:00
Lixin Guo c02d39ea57 tests: userspace: add support for K_OBJ_CONDVAR
add support for K_OBJ_CONDVAR in test_alloc_kobjects()
This improves the code coverage.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2021-12-06 08:06:45 -05:00
Lixin Guo 350a13566e tests: userspace: add support for validating invalid objects
test userspace API with invalid kernel objects.
This improves code coverage.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2021-12-06 08:06:45 -05:00
Johann Fischer 35691d21d8 tests: thread_apis: fix cast to smaller integer type
Clang 12.0.0 complains about
"cast to smaller integer type 'enum control_method' from 'void *'
[-Werror,-Wvoid-pointer-to-enum-cast]".
Cast it to intptr_t type first.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-12-04 12:09:54 +01:00
Gerard Marull-Paretas 618609dc2c tests: kernel: device: remove PM related tests
The PM subsystem is tested in tests/subsys/pm, the removed tests were
not relevant for devices. The test_build_suspend_device_list test has
been renamed to test_device_list since the API is not strictly related
to PM (and does not depend on it).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-12-02 10:53:39 +01:00
Carlo Caione 26856ca878 test: device: Specify address and size cells.
The test is wrongly assuming that all the archs have #address-cells =
<1> and #size-cells = <1> at the DT root. This is not always true, and
it makes the test failing for AArch64. Fix the wrong assumption.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-11-29 19:41:27 -05:00
NingX Zhao cb4a629bc8 tests: removing incorrect testcases of poll
These two test cases both are fault injection test cases,
and there are designed for testing some negative branches
to improve code coverage. But I find that this branch
shouldn't be tested, because the spinlock will be locked
before a procedure performs here, and then it will trigger
an assert error and the process will be rescheduled to the
handler function, and terminated the current test case,
so spinlock will never be unlocked. And it will impact
the next test case in the same test suite(the next testcase
will be never get spinlock).

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2021-11-29 18:26:02 -05:00
Christopher Friedt 7ea93a8853 tests: kernel: cycle64: mark test as slow
Previously cycle64 was under `samples/`. It's been moved to
`tests/` and has been marked with `slow: True` so that it
will not disrupt CI by adding excessive delays.

Fixes #40367

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-11-29 10:35:49 -05:00
Gerard Marull-Paretas 57d41addd4 tests: kernel: device: add missing include
<pm/device.h> header is now required after #40693, this test was missed.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-29 10:33:41 -05:00
Flavio Ceolin 6451626ce7 pm: Use pm_device_action_run instead of state_set
Since drivers implement a callback based on action and not the state,
we should be using the API based on the action instead of the one based
on the state.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-11-24 14:21:50 -05:00
Andy Ross 201c3ce47c tests/kernel: Add test for CONFIG_SMP_BOOT_DELAY
This feature is in tree and used by the SOF app, but we don't have a
local test for it.  Add one, including a case to track regressions in
a known failure mode (where the second CPU wouldn't get its IDC
interrupts set up correctly if spawned at runtime).

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-11-23 13:23:54 -05:00
Daniel Leung bb595a85f1 kernel: mem_domain: add/remove partition funcs to return errors
This changes both k_mem_domain_add_partition() and
k_mem_domain_remove_partition() to return errors instead of
asserting when errors are encountered. This gives the application
chance to recover.

The arch_mem_domain_parition_add()/_remove() will be modified
later together with all the other arch_mem_domain_*() changes
since the architecture code for partition addition and removal
functions usually cannot be separately changed.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-11-22 12:45:22 -05:00
Daniel Leung fb91ce2e21 kernel: mem_domain: init function to return error values
This changes k_mem_domain_init() to return error values
instead of asserting when errors are encountered.
This gives applications a chance to recover if needed.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-11-22 12:45:22 -05:00
Daniel Leung 2ffd49310a tests: mem_protect/mem_protect: more tables for QEMU Cortex A53
For qemu_cortex_a53 on the mem_protect test, the test
test_mem_domain_init_fail() fails due to not having enough
translation tables. However, since ARM64 MMU asserts on such
condition, and k_mem_domain_init() also asserts when fails,
there is no way to distinguish these two assertions at runtime,
thus the test was considered passing. Fix this by allocating
a few more tables so the test will actually fail on
k_mem_domain_init().

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-11-22 12:45:22 -05:00
Gerard Marull-Paretas 39f21dc116 tests: pm: use new PM macros
Use PM_DEVICE_STATE_DEFINE to define PM state.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-19 10:11:32 +01:00
Christopher Friedt ed7eec4c94 tests: kernel: atomics: expand atomic operations to 64-bit
This change updates the atomic tests to validate 32-bits on
32-bit architectures and 64-bits on 64-bit architectures.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-11-15 09:59:01 -05:00
Lixin Guo 21e1e8cf23 tests: work_queue: add a test case for coverage
Add a test case for k_work_poll_cancel() API.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2021-11-12 11:56:23 -05:00
Lixin Guo bbe8f182c7 tests: timer: fix improper test identifier
The test identifier of timer error case in testcase.yaml is
exactly the same as timer api's test identifier.
So I fix this.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2021-11-09 22:42:12 -05:00
Enjia Mai 704e7ce30f tests: correct some testsuite name
Some of the testsuite names are duplicated. Try to rename them
to adequate ones.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2021-11-09 15:51:44 -05:00
Andy Ross 904a6c0319 tests/thread_apis: Fix whitebox assumptions in runtime_stats test
The thread_apis tests of the RUNTIME_STATS feature weren't really
testing the right behavior.

+ It assumed that accounting would only happen at context switch time
  and required that the returned values not change for running threads
  (even CLEARLY running threads like _current!).  But that's not a
  documented feature!  It's actually sort of a wart that we'd like to
  be able to fix (and have fixed, the new backend returns realtime
  values so you can track CPU-bound processes on another CPU).

+ It assumed that k_thread_runtime_stats_all_get() would return time
  that includes idle time (or conversely it forgot that
  k_thread_foreach enumerates over idle threads).  This was sort of a
  bug in the original (because it means that the result is always the
  system uptime multiplied by the number of CPUs)

Broadly, instead of testing the result of a "time" function for
equality (never a good idea) test it via appropriate bounds given the
usage.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-11-08 21:32:20 -05:00
Christopher Friedt 964b153f96 tests: clock: tests for k_cycle_get_64
This change adds tests for 64-bit cycle counters.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-11-08 13:41:53 -05:00
Lixin Guo 72dba936cb tests: heap: add test case for coverage
Add a test case for k_heap_aligned_alloc API.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2021-11-07 05:39:10 -05:00
Flavio Ceolin dd152c2b89 pm: policy: Add cpu information in the API
On multicore environments the policy may need to know which CPU is
idle.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-11-06 10:21:53 -04:00
Gerard Marull-Paretas 18519ffe8d tests: use common PM action callback naming
The PM callback is no longer referenced as "pm_control" but
"pm_action_cb", so reflect this new naming on the callbacks.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-03 20:27:18 -04:00
Ying ming 56ef5aac52 test: change test suite name and testcase name
Because there are two testcases be the same name
in directory tests/kernel/sched/, so change one of
them to avoid confusion.

Signed-off-by: Ying ming <mingx.ying@intel.com>
2021-11-03 16:44:50 -04:00
Gerard Marull-Paretas 1cee284a46 pm: device: runtime: use pm_device_runtime* namespace
Move all PM device runtime API calls from pm_device* to the
pm_device_runtime* namespace.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-03 16:37:33 -04:00
Krzysztof Chruscinski 5d73d81ca1 tests: kernel: mem_slab: Fix test for no multithreading
Modified test to exit early when multithreading is disabled to
fix linking errors.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-11-03 09:18:40 -04:00
Christopher Friedt 213ad01ed0 tests: kernel: disable one test for qemu_cortex_a9
Currently a test is failing.

```
twister -i -p qemu_cortex_a9 \
  -s tests/kernel/fatal/exception/kernel.common.stack_sentinel
```

Disable those temporarily until a fix is in place.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-11-01 22:10:04 -04:00
Lixin Guo a13b907398 tests: mslab: add test case for coverage
Add test case to test thread pending operation
in k_mem_slab_alloc() API.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2021-11-01 11:17:09 -04:00
Lixin Guo 4b9b30c99d tests: msgq: improve code coverage for msgq API
This improves code coverage for the branch whether
write pointer in message queue reaches buffer end.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2021-11-01 11:15:15 -04:00
Lixin Guo 7fb38330f6 tests: queue: add a test case for coverage
Add a test case for k_queue_unique_append() API.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2021-10-28 12:06:25 -04:00
Lixin Guo 5b9c6264af tests: userspace: add a test for code coverage
Add a test case for getting all the kernel objects in
kobject list.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2021-10-28 12:01:01 -04:00
Immo Birnbaum 52a5c08325 tests: enable kernel test fatal/exception for aarch32 Cortex-A CPUs
Add consideration of aarch32 Cortex-A CPUs to a test case in which
architecture-specific assembly instructions are used in order to
explicitly trigger an exception. This test case already considers
aarch32 Cortex-R CPUs, the same instruction will be used by
Cortex-A CPUs.

Signed-off-by: Immo Birnbaum <Immo.Birnbaum@Weidmueller.com>
2021-10-28 15:26:50 +02:00
Lixin Guo 2643e8d62d tests: mutex: fix improper test identifier
The test identifier of mutex error case in testcase.yaml is
exactly the same as mutex api's test identifier.
So I fix this.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2021-10-20 10:19:18 -04:00
Peter Mitsis 10637afc00 tests: add event test code
Adds both kernel and user space test code for the events API.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2021-10-16 06:27:10 -04:00
Lixin Guo fb18038e55 tests: stack: fix improper assert message
I find that there has a description error and a spelling
mistake in assert message. So I fixed this.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2021-10-13 06:17:23 -04:00
Lixin Guo d460a6361d Test: stack: add a test case for code coverage
Add a testcase for stack_alloc_init API.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2021-10-13 06:17:02 -04:00
Keith Short 0bfde7bc5d tests: Add PM control to dummy_driver
Add the pm_control fn to the dummy_driver so the full PM API is tested.
This change also bypasses all PM APIs if the device driver doesn't
support PM.

Signed-off-by: Keith Short <keithshort@google.com>
2021-10-13 06:16:13 -04:00
Carlo Caione 43cb00df08 multi_heap: Introduce shared multi-heap memory pool manager
The shared multi-heap memory pool manager uses the multi-heap allocator
to manage a set of reserved memory regions with different capabilities /
attributes (cacheable, non-cacheable, etc...) defined in the DT.

The user can request allocation from the shared pool specifying the
capability / attribute of interest for the memory (cacheable /
non-cacheable memory, etc...)

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-10-12 07:44:46 -04:00
Flavio Ceolin 5027c356cd test: pm: device: Fix build options
The test is using device and device runtime power management. Just
including them to the test build.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-10-07 15:44:32 -04:00
Andy Ross 13d3036e37 tests/msgq_usage: Correct memory usage for cache-incoherent platforms
When CONFIG_KERNEL_COHERENCE=y (e.g on the various intel_adsp
platforms under SMP) it's not legal to share stack memory between
CPUs, because the stack is cached, and the L1 cache is incoherent.
The kernel will automatically detect the mistake when the memory
contains a kernel object (spinlock, IPC object, etc...).  But here the
test was just passing async buffers into the msgq layer, and nothing
watches that.

The fix is simple: make them static.

Fixes #35857

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-10-06 17:40:53 -04:00
Andy Ross f3ed0feb47 tests/kernel/mheap_api_concept: Add sys_multi_heap test
Add a simple coverage test for the multi_heap utility, validating all
cases with a simple configuration value that specifies an index in an
array of heaps.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-10-01 20:38:35 -04:00
Alexandre Bourdiol 25432ecfa4 tests: kernel: sched: schedule_api: enlarge timeslice criterion
From time to time, measured slice time is one less/more than requested.
Fixes #35793

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2021-09-30 20:39:31 -04:00
Lixin Guo a5a360d319 Tests: memory protect: add some error test cases
Add some error case for adding and removing memory partition
API.

Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
2021-09-29 06:29:19 -04:00
Andy Ross 0f20abda8d tests/kernel/threads_apis: Add case for CPU_MASK_PIN_ONLY
Add testing for the PIN_ONLY API variant (which has a separate run
queue per CPU).  Predicate on SMP systems only, to keep needless
duplicate testing to a minimum.

Note that one of the cases in this test exercises an "all cpus" option
for the cpu mask, which is illegal when CONFIG_SCHED_CPU_MASK_PIN_ONLY
is set.  Skip.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-09-28 20:15:05 -04:00
Yuguo Zou 5b590faab5 tests: threads: fix kernel/thread_stack test
Fix the broken logic in the kernel/thread_stack test
The modified test should do direct read & write from estimated stack
pointer to highest address in the stack buffer.
Previously this test was start from lowest address in the stack
which would trigger exception of hardware stack checking scheme
violation on ARC boards and other targets with hardware stack
overflow detection.

Signed-off-by: Yuguo Zou <yuguo.zou@synopsys.com>
2021-09-27 12:25:12 -04:00
Naiyuan Tian 1f99a0ca18 tests: threads: fix uninitialized scalar variable
In the file variable val is not initialized,
causing the variable stack_ptr, pos, points to uninitialized data.
Initialize the variable val according to the code and commits.

Fixes #37916

Signed-off-by: Naiyuan Tian <naiyuan.tian@intel.com>
2021-09-17 22:30:50 -04:00
NingX Zhao ca4c71ca02 tests: thread: Add an initialization
Add an initialization to the global variable to make sure testcases
can be ran correctly.

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2021-09-17 10:30:54 -04:00
Chen Peng1 0774ce94ed tests: mem_map: limit memory below 0x10000000 on up_squared.
there is a memory hole from address 0x10000000-0x12150fff
in the ram on up_squared, we don't have access to read/write
this range, so limit the memory range below 0x10000000.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2021-09-16 09:32:36 -04:00
Francois Ramu 30db452aec tests: kernel: timer api with real time slot in test_sleep_abs
This patch is testing the test_sleep_abs with a longer
real time slot value. The reason is that for platforms
like stm32wb55rg with PM, the real time slot must be adjusted
because of the LPTIM ticker.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-09-10 16:20:30 -04:00
Enjia Mai 495d10234d tests: common: add test for ffs function
Add a testcase for find_msb_set() and find_lsb_set() functions.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-09-07 11:30:43 -04:00
Nicolas Pitre 5a384b9ea8 lib/os/cbprintf_nano.c: avoid sign extension on unsigned formats
There might be a sign extension when a long is promoted to
int_value_type and the former type is smaller than the later.
This produces the wrong output if the specified format is unsigned.

Let's avoid this problem by handling signed and unsigned cases
explicitly. When the type already matches int_value_type then the
compiler is smart enough to recognize the redundancy and removes
unneeded duplications automatically, meaning that the code will stay
small when code size matters.

A similar issue also existed in the restricted %llu case.
The fix is the same as above.

Those fixes exposed wrong results in the printk.c test with %llx
so fix that as well.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-09-02 19:37:06 -04:00
Filip Kokosinski 19fc1ee77c subsys/random: change parameters for timer-based PRNG
PR #36996 disabled running mem_protect/stack_random test on qemu_riscv32
platform because of this test consistently failing on said platform.
This test starts new threads in equal time intervals, and because of
that we get repeating values after performing the modulus operation when
calculating the stack pointer address.

This can be solved by changing the value of the _RAND32_INC constant
that is used to increase the value returned by the timer-based PRNG.

This commit decreases the value of the mentioned constant from
1000000013U to 1000000003U.

Fixes #37006.

Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
2021-08-30 09:32:36 -04:00
Torsten Rasmussen 2760fb9eda tests: added kernel tests for arm arch with linker script generator
This commit adds an additional test case for several kernel test suites
to ensure that the linker script generator is working correctly for a
subset of the Zephyr test suites.

The ensures that the basic functionality of the linker script generator
is working while still keep the performance impact on CI at a minimal
level.

Using the kernel tests is a trade-off between testing coverage of the
linker script generator and the time it takes to complete CI.

The kernel tests is considered to have the broadest coverage of various
features important for the generated linker script.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Torsten Rasmussen c6aded2dcb linker: align _image_rodata and _image_rom start/end/size linker symbols
Cleanup and preparation commit for linker script generator.

Zephyr linker scripts provides start and end symbols for each larger
areas in the linker script.

The symbols _image_rom_start and _image_rom_end corresponds to the group
ROMABLE_REGION defined in the ld linker scripts.

The symbols _image_rodata_start and _image_rodata_end is not placed as
independent group but covers common-rom.ld, thread-local-storage.ld,
kobject-rom.ld and snippets-rodata.ld.

This commit align those names and prepares for generation of groups in
linker scripts.

The symbols describing the ROMABLE_REGION will be renamed to:
_image_rom_start -> __rom_region_start
_image_rom_end   -> __rom_region_end

The rodata will also use the group symbol notation as:
_image_rodata_start -> __rodata_region_start
_image_rodata_end   -> __rodata_region_end

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-28 08:48:03 -04:00
Flavio Ceolin 2549160d69 pm: device: Remove PM_DEVICE_STATE_FORCE_SUSPEND
This is not a state but an action. Just remove it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-08-27 17:47:10 -04:00
Daniel Leung 27f36bda51 boards: qemu_x86_tiny: enabled for general demand paging testing
This enables qemu_x86_tiny to be used for more general demand
paging testing where non-pinned code and data is not available
in physical memory at boot. This adds a custom linker script to
qemu_x86_tiny for pinning code and data. In the process, a new
kconfig CONFIG_BOARD_QEMU_X86_TINY has to be introduced to
distinguish from other qemu_x86* boards. This linker script
is based on the generic x86-32 one in
include/arch/x86/ia32/linker.ld, with additions to
put symbols into boot and pinned sections.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-26 21:16:22 -04:00
Daniel Leung 1203289143 tests: mem_protect/mem_map: pin test_page in memory
This pins the test_page in memory for tests about memory
mapping. This is simply to make sure the whole array
is in physical memory for mapping or else the mapping
function would fail due to having nothing to map.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-26 21:16:22 -04:00
Daniel Leung ba94780662 tests: device: pin symbols for testing with demand paging
There are quite a few symbols which are needed before the paging
mechanism is initialized. So they need to be pinned in memory
to prevent page fault early in the boot process.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-26 21:16:22 -04:00
Daniel Leung 802b55bb50 tests: mbox_api: a bit more stack for qemu_x86_tiny
For testing on qemu_x86_tiny, a little bit more stack is needed.
So add the extra stack for testing.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-26 21:16:22 -04:00
Daniel Leung bb1656abc6 tests: mem_protect/userspace: _k_neg_eagain maybe in pinned sect
If pinned section is enabled, _k_neg_eagain should be in pinned
rodata section. So add the check if pinned section is enabled.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-26 21:16:22 -04:00
Daniel Leung 46ae0a5664 tests: demand_paging: pin fatal error handler
This puts the fatal error handler into pinned sections so
it can be used to handle fatal errors without causing
page faults.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-26 21:16:22 -04:00
Daniel Leung b70d44c94d tests: fatal/exception: pin stack before stack overflow test
For hardware stack overflow test, pin the whole stack if
demand paging is enabled and generic sections are not all present
at boot. The whole stack may not be in memory at the time of
test, which would result in double fault (exception being
handled + page fault). So make sure the stack is in physical
memory and mapped before doing any tests.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-26 21:16:22 -04:00
Naiyuan Tian 66c931dbd4 tests: interrupt: fix typos in the commits
While reading the code, find typos in the code commits.
tests:kernel:interrupt:src:dynamic_isr, line 110 and 115.

Signed-off-by: Naiyuan Tian <naiyuan.tian@intel.com>
2021-08-26 06:54:55 -04:00
Naiyuan Tian 4cb1f0ef94 tests: common: fix typos in the commits
While reading the code, find typo in the code comment.
In file irq_offload.c, line 163.

Signed-off-by: Naiyuan Tian <naiyuan.tian@intel.com>
2021-08-26 06:54:55 -04:00
Michał Barnaś 5a1fcb609c doc: replace courge with corge
Grault and corge are both syntactical variables used globally.
Courge is misspelling of corge.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2021-08-23 18:54:27 -04:00
Torsten Rasmussen 1cccc8a8fe cmake: increase minimal required version to 3.20.0
Move to CMake 3.20.0.

At the Toolchain WG it was decided to move to CMake 3.20.0.

The main reason for increasing CMake version is better toolchain
support.

Better toolchain support is added in the following CMake versions:
- armclang, CMake 3.15
- Intel oneAPI, CMake 3.20
- IAR, CMake 3.15 and 3.20

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-20 09:47:34 +02:00
NingX Zhao c0d18079cc poll: add a testcase to detect is_polling
Add a testcase to detect is_polling, to avoid some
issues.

Fixed #12405

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2021-08-18 20:09:01 -04:00
Bradley Bolen 60f23a5dc2 tests: userspace: Add Cortex-R test
Try to read the stclr register from userspace.  This should generate an
exception.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2021-08-17 06:06:33 -04:00
Bradley Bolen ce85892916 tests: mem_protect: syscalls: Add bad address for qemu_cortex_r5
The default address for FAULTY_ADDRESS is valid on the qemu_cortex_r5
board, so use a value that is not mapped for that board.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2021-08-17 06:06:33 -04:00
Enjia Mai ee327803e3 tests: common: skip arch_nop testing on some physical x86 board
Using the NOP instructions to do timing control on some physical board
such as ehl_crb, up_squared and intel adsp board, that doesn't work.
It seems like it can only be used for instruction alignment purposes.
We skip this test on this board because it's not meaningful.

Fixes #35971

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-08-06 20:20:32 -04:00
Gerard Marull-Paretas d41dadc569 pm: rename PM_DEVICE_STATE_SUSPEND to PM_DEVICE_STATE_SUSPENDED
The verb tense for the suspended state was not consistent with other
states. The likely reason: state was being used as a command/action.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Johann Fischer 3240e0cc51 tests: remove USB configuration option
Remove USB configuration option, replace it where necessary
with USB_DEVICE_STACK.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:00:12 -04:00
Enjia Mai c2ac8fe7d7 acrn_ehl_crb: fix the incorrect configuration of timer IRQ priority
The default CONFIG_APIC_TIMER_IRQ_PRIORITY is 4, but it should be 1 for
ACRN. That's why the testcase failed due to no timer interrupt was
triggered.

And we also temporary adjust the testing IRQ for dynamic isr due to it
conflict with the IRQ of the APIC TSC deadline TIMER.

Fixes #36203.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-08-03 07:30:15 -04:00
Gerard Marull-Paretas 6c3beb928e pm: adjust busy check API call return types and naming
Busy check APIs now return boolean type. Due to that change, the
function names have also been adjusted. The common name pattern for
boolean check type APIs is "PREFIX_is_CONDITION". For example,
"pm_device_is_busy".  pm_device_busy_check has been renamed to
pm_device_is_busy and pm_device_any_busy_check to pm_device_is_any_busy.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-30 09:28:42 -04:00