Commit Graph

1853 Commits

Author SHA1 Message Date
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
Gerard Marull-Paretas 90c61a3702 tests: kernel: device: remove redundant busy set and clear
The test_dummy_device test has nothing to do with device busy testing,
so remove the calls to pm_device_busy_set/pm_device_busy_clear.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-30 09:28:42 -04:00
Gerard Marull-Paretas 70322853a8 pm: device: move device busy APIs to pm subsystem
The following device busy APIs:

- device_busy_set()
- device_busy_clear()
- device_busy_check()
- device_any_busy_check()

were used for device PM, so they have been moved to the pm subsystem.
This means they are now prefixed with `pm_` and are defined in
`pm/device.h`.

If device PM is not enabled dummy functions are now provided that do
nothing or return `-ENOSYS`, meaning that the functionality is not
available.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-30 09:28:42 -04:00
Flavio Ceolin 96d5a58a46 tests: profiling: Remove unnecessary stubs
It is not necessary to implement stubs for system pm functions.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-07-26 04:31:54 -04:00
Daniel Leung 9debd59368 tests: schedule_api: use stack array extern macro
The stack array tstacks was declared in the header file using
the same macro which defines the same stack array but with
an added "extern" in front. This macro adds alignment and section
attribute which are actually not the same as the actual stack array
defined in main.c. The section name used in the section attribute
contains the file name where the stack array is defined or extern
declared. So the same symbol, in this case z_interrupt_stacks, has
different attributes in two places, and GCC 11 starts to complain
about this. So use the newly introduced macro to extern declare
the stack array without adding/replacing any symbol attributes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-07-22 07:24:11 -05:00
Daniel Leung 15a46cfee4 tests: mem_protect: fix warning on uninitialized variable
In test_kobject_release_null(), dummy is not initialized
before being fed to k_object_release(). So set it.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-07-22 07:24:11 -05:00
Daniel Leung e3704ccda3 tests: kernel/common: avoid using compiler builtin popcount
Not all arch has native support for __builtin_popcount() on
hardware and GCC falls back in using software only implementation.
However, with GCC 11, this is no longer included automatically
and requires linking explicitly with libgcc.a. This is not
trivial as it requires changes some linker magic and a sizable
change to most linker scripts. So opt for an easy solution
by implementing our own popcount in the test.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-07-22 07:24:11 -05:00
Christopher Friedt a87a5ea22b tests: kernel: mem_protect: stack_random: disable qemu_riscv32
Test fails consistently in CI but local builds succeed. Puzzling. In
order to keep main green, disabling this test only for qemu_riscv32
until a solution is found.

```
% west build -p always -b qemu_riscv32 -t run \
  tests/kernel/mem_protect/stack_random
...
*** Booting Zephyr OS build zephyr-v2.6.0-1039-g523764b3fd75  ***
Running test suite stack_pointer_randomness
===================================================================
START - test_stack_pt_randomization
Test Stack pointer randomization
stack pointer changed 13 times out of 64 tests
 PASS - test_stack_pt_randomization in 0.5 seconds
===================================================================
Test suite stack_pointer_randomness succeeded
===================================================================
PROJECT EXECUTION SUCCESSFUL
```

```
*** Booting Zephyr OS build zephyr-v2.6.0-1063-g0106d8f2a391  ***
Running test suite stack_pointer_randomness
===================================================================
START - test_stack_pt_randomization
Test Stack pointer randomization
stack pointer changed 0 times out of 64 tests
 Assertion failed at WEST_TOPDIR/zephyr/tests/kernel/mem_protect/\
  stack_random/src/main.c:68: test_stack_pt_randomization: \
  (sp_changed equal to 0)
 Stack pointer is not randomized
FAIL - test_stack_pt_randomization in 0.6 seconds
===================================================================
Test suite stack_pointer_randomness failed.
===================================================================
PROJECT EXECUTION FAILED
```

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-07-16 14:48:21 -04:00
Kumar Gala ab9d935fed tests: kernel: device: Exclude beaglev_starlight_jh7100
We excluded the beaglev_starlight_jh7100 from this test but only did
the kernel.device.pm test.  We should have excluded the platform
from both tests.

The beaglev_starlight_jh7100 uses a full 64-bit devicetree map
which uses #{address/size}-cells = 2.  The device test expects
that #{address/size}-cells = 1 so exclude beaglev_starlight_jh7100
from the test.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-07-14 16:12:57 +03:00
Hake Huang 3a3ca2b3b2 tests: add min_ram to test applications
add min_ram to some test applications
as we found below platforms have size issues
TWR_KE18F and FRDM_KL25Z

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2021-07-13 10:20:18 -05:00
Gerard Marull-Paretas 26ad8376bd pm: remove callback from control function
The callback is not used anymore, so just delete it from the pm_control
callback signature.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-13 09:36:45 -04:00
Gerard Marull-Paretas 1b716cfe3a tests: kernel: device: fix incorrect device power state type
The type used by device PM state was not changed to the recently
introduced enum type. The state is also initialized to a value distinct
from the first expected value.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-08 12:08:20 -05:00
Anas Nashif 8581b6d1f0 tests: remove kernel tag from key tests/samples
Thos tests/samples are used to build any PR onl all available boards to
verify basic sanity. Having the kernel tag means they can get excluded
for random non-kernel changes causing regressions. so remove kernel tag
to keep them in all CI runs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-07-08 08:59:51 -04:00
Gerard Marull-Paretas cc2f0e9c08 pm: use enum for device PM states
Move all PM_DEVICE_STATE_* definitions to an enum. The
PM_DEVICE_STATE_SET and PM_DEVICE_STATE_GET definitions have been kept
out of the enum since they do not represent any state. However, their
name has not been changed since they will be removed soon.

All drivers and tests have been adjusted accordingly.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-07 14:13:12 -04:00
Kumar Gala 1e71415214 tests: kernel: device: Exclude beaglev_starlight_jh7100
The beaglev_starlight_jh7100 uses a full 64-bit devicetree map
which uses #{address/size}-cells = 2.  The device test expects
that #{address/size}-cells = 1 so exclude beaglev_starlight_jh7100
from the test.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-06-30 13:39:52 -04:00
Watson Zeng e451bf44fe tests: mem_protest: workaround aggressive optimization
We have some static variables var, zeroed_var and bss_var
in mem_partition.c and we only assert the value of them in
the same file, so the compiler may pre-calculate it in compile
stage, it's fine usually.
But for variable zeroed_var (= 20420), we force to put it in bss
section in link stage, the value will change in bss clean stage, so
we will get a wrong result.
Let's add volatile for these variables to disable pre-calculation.

Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
2021-06-28 09:15:43 -04:00
Ioannis Glaropoulos 1a7228a462 tests: add fpu tag the tests which enable FPU and FPU_SHARING options
Introduce the fpu tag to tests that explicitly enable
the FPU and FPU_SHARING Kconfig options. The tag could
be used to run all FPU-related tests in the tree.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-06-22 08:45:41 -04:00
Mulin Chao 38eaabc9c7 tests: kernel: gen_isr_table: Add workaround for npcx9 series.
Both NPCX7/9 uses the IRQs at the end of the vector table, for example,
the IRQ 60 and 61 used for Multi-Input Wake-Up Unit (MIWU) devices by
default, and conflicts with ISR used for testing.

This CL changes TEST_NUM_IRQS (The value is changed from 46 to 44) to
move IRQ used for this test suite from 42 to 40 which is reserved in
both NPCX7 and NPCX9 series to resolve the issue.

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
2021-06-08 00:40:14 -04:00
Anas Nashif 86209aced7 boards: qemu_x86_coverage: remove board testing coverage
This board was added to test coverage feature when coverage was
introduced. This is now being testing with other boards and
configurations on a regular basis, so no need for this extra overhead in
CI.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-06-01 14:06:56 -05:00
Daniel Leung dfa4b7e375 kernel: mmu: z_backing_store* to k_mem_paging_backing_store*
These functions are those that need be implemented by backing
store outside kernel. Promote them from z_* so these can be
included in documentation.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-28 11:33:22 -04:00
Daniel Leung 31c362d966 kernel: mmu: rename z_eviction* to k_mem_paging_eviction*
These functions and data structures are those that need
to be implemented by eviction algorithm and application
outside kernel. Promote them from z_* so these can be
included in documentation.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-28 11:33:22 -04:00
Ioannis Glaropoulos d105a2b76c arm: shrink names for null-pointer exception detection Kconfigs
Reduce the length of the Kconfig defines related to
null-pointed dereference detection in Cortex-M.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-05-26 12:30:05 -05:00
Daniel Leung 8fd3d18b40 tests: kernel/common: incorrect use of k_poll in timeout order
In the timeout order test, the usage of k_poll() assumes that it
only returns after all events are ready. However, that is not
the case, as k_poll() returns when non-zero number of events are
ready. This means the check for all semaphore being ready after
k_poll() will not always pass. So instead of using k_poll(),
simply wait a bit for timers to fire, then check results.

Also add some bits to clean up at the end of test.

Fixes #34585

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-25 07:34:59 -05:00
Nicolas Pitre b8d24ffb45 arm64: mitigate FPU-in-exception usage side effects
Every va_start() currently triggers a FPU access trap if FPU is not
already used. This is due to the fact that va_start() must copy FPU
registers that are used for float argument passing into the va_list
object. Flushing the FPU context to its owner and granting access to
the current thread is wasteful if this is only for va_start(),
especially since in most cases there are simply no FP arguments
being passed by the caller.

This is made even worse with exception code (syscalls, IRQ handlers,
etc.) where the exception code has to be resumed with interrupts
disabled upon FPU access as there is no provision for preserving an
interrupted exception mode's FPU context.

Fix those issues by simply simulating the sequence of STR instructions
that the va_start() generates without actually granting FPU access.
We limit ourselves only to exception context to keep changes to a
minimum for now.

This also allows for reverting the ARM64 exception in the nested IRQ
test as it now works properly even if FPU_SHARING is enabled.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-05-21 04:52:44 -05:00
Andy Ross 3953e07822 tests/kernel/mem_heap: Add minimum-size heap test
Add test to statically allocate a minimum-size heap, verify that it
works to allocate a single byte and that it doesn't overrun its memory
bounds.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-05-20 17:52:21 -04:00
Enjia Mai 04c736d98d tests: interrupt: refine the offload case not rely on delay timing
The interrupt offload testcases fail on some boards because the timing
of the delay is too short. Refine the testcases and make it not rely
on the delay timing.

Fixes #35097
Fixes #35241

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-05-20 17:34:09 -04:00
Henrik Brix Andersen aa78a6473b tests: kernel: gen_isr_table: do not use IRQ 57 on NXP LPC55S16
IRQ 57 is reserved in the NXP LPC55S16 SoC. Thus, limit the number of
interrupts reported to the test, so that it does not try to use it.

Fixes #34915

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2021-05-19 16:16:32 -05:00
Anas Nashif 1e74ddd709 kernel: remove dead workq code
work_q.c is not being built or used, it was replaced by user_work.c
which now has k_work_user_queue_start.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-18 11:21:27 -05:00
Andy Ross d058ed3011 tests/kernel/fatal: Don't swap while locked
This test takes an interrupt lock and tries to call z_swap_unlocked()
while holding it.  That's not legal (in the general case it means
you're breaking a caller's lock!), though in this particular case it
was safe because we'll never return to this.

Regardless, there is a natural z_swap_irqlock() that releases the lock
atomically.  Use that.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-05-17 15:27:37 -04:00
Andy Ross 58bc81573f tests/kernel/common: Remove needless 1cpu limitation from test_clock_uptime
It's not at all clear to me why this was set to 1cpu, it's a single
thread doing sequential things.  (I tripped over it because the 1cpu
happened to tickle an unrelated arm64 bug with interrupt state.  But
we might as well fix it here.)

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-05-17 15:27:37 -04:00
Andy Ross 2a7edbdbd6 tests/kernel/smp: Remove release_global_lock_irq case
This test case was taking a (traditional) irq_lock(), which masks
interrupts, and then calling k_mutex_lock() with a timeout of
K_FOREVER, which is a blocking call.  That's not legal, because it
will obviously schedule other threads to run in a context where the
code was promised it would not.  This used to be an uncaught error,
but now we have an assertion that catches this.

It's not clear what this test case is supposed to be testing, as the
behavior is actually identical to the release_global_lock case except
for the (incorrect) addition of the irq_lock().  If this is needed for
code coverage we can work to figure out the real root cause of the
missing coverage later.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-05-17 15:27:37 -04:00
Anas Nashif 009dee157d doc: fix doxygen grouping
Fix various grouping issues in doxygen and name groups correctly in some
cases.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-17 11:51:44 -04:00
Andy Ross 653e7a28ea tests/kernel/common: Skip bitarray tests when KERNEL_COHERENCE
Kernel objects that contain embedded synchronization structures like
spinlocks can't be palced in the (cached/incoherent) stack memory on
coherence platforms like intel_adsp.

The normal fix in a test case is just to make the offending data
static, but that's painful here because SYS_BITARRAY_DEFINE declares
two objects (i.e. you can't put a "static" in front of it as with
similar macros) and it happens to be used in this case to define local
variables with collliding names, so I'd have to go in and rename
everything.

And there's little value anyway.  Bitarrays are nearly-pure data
structures and extremely unlikely to show up platform-dependent
behavior.

Fixes #35242

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-05-15 15:28:43 -04:00
Enjia Mai 05d8c6fc78 tests: kernel: fix two semaphroe testcases failed on ADSP
Two testcases of semaphore failed in ADSP due to the timeout value
we got back from the child thread is invalid. We put the variable in
the bss instead of in a stack, trying to avoid this.

Fixes #34687

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-05-14 16:41:21 -04:00
Watson Zeng 3e369f935c tests: msgq_usage: ensure all services started before client query
add semaphores to ensure all services started before client query.
otherwise client query services may fail.

Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
2021-05-13 22:03:55 -04:00
Andy Ross 6941c8fda9 tests/kernel/smp: Misc synchronization fixups
A few mistakes in recent changes to this test:

There was a "LOCK_NO" (i.e. no locking!) case being exercised in
test_inc_concurrency, where three threads would race against each
other incrementing and decrementing a single count without
synchronization.  And... it failed on cAVS.  Because there was no
synchronization.  Just remove.

The LOCK_IRQ (irq_un/lock()) case of the same test was was casting
taking a pointer to an integer (that stored the irq_lock() result) and
casting the pointer value to an integer instead of dereferencing it.

Also the workq test had a work item on the stack, which is forbidden
when KERNEL_COHERENCE=y

Fixes #34152

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-05-13 22:03:05 -04:00
Enjia Mai e2f6b9536c tests: interrupt: fix coverity issue of newly added testcases
Should not use -1 as an input parameter for unsigned int. Use zero
instead of -1 as invaild interrupt number to fix coverity warning.

Fixes #35146
CID: 235994

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-05-13 22:02:47 -04:00
Enjia Mai 36a1a88884 tests: smp: correct the inappropriate testcase
Update testcase test_fatal_on_smp(), and refine it and correct some
inappropriate usage such as unnecessary irq_lock(). This prevents
the error propagation to the later executing testcase.

Fixes #35200
Fixes #35202

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-05-12 17:04:20 -04:00
Watson Zeng f100566f7a tests: mheap_api_concept: fix non-reentrant thread_id
in test case test_mheap_threadsafe, we will create 3 threads using
same thread handler tmheap_handler, we should make thread_id
to be a local variable, otherwise tmheap_handler is non-reentrant.

Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
2021-05-12 08:30:46 -05:00
Daniel Leung fb88c77ac2 tests: mem_protect/mem_map: remove unused assignment to cnt
The variable cnt is assigned twice in a row, so remove
the first one.

Coverity-CID: 235962
Fixes #35161

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-11 15:45:39 -05:00
Erwan Gouriou 77a751ecf9 tests/kernel/common: Fix test test_nop for ARMV7_M_ARMV8_M_MAINLINE
Treat ARMV7_M_ARMV8_M_MAINLINE similarly to ARMV6_M_ARMV8_M_BASELINE
and add arch_nop() calls to test_nop function.
Additionally add one arch_nop() call to fit comment and update
comments when required on other archs.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-05-11 07:15:17 -05:00
Enjia Mai 0622bde3bf tests: condvar: fix one testcase failure on qemu_cortex_a53_smp
After enabled FPU context switch, one condvar testcase failed due to
the order of spawning thread cannot be guaranteed. Add a delay to
make sure the thread which initializing the condvar run first.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-05-08 17:08:48 -04:00
Enjia Mai a7d8ff40aa tests: common: fix newly added test_nop failing the CI
The newly added testcase test_nop failed the CI. Give RISCV more
arch_nop() instructions to archieve one cycle.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-05-08 17:08:17 -04:00