Commit Graph

2182 Commits

Author SHA1 Message Date
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 d2f8ec7023.

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