zephyr/tests/kernel/context
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jamie McCrae 1538034c97 tests: kernel: Fix changing SoC specific Kconfig
Fixes wrongly setting a Kconfig for all devices for a Kconfig
that is SoC specific and moves it directly to the test

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-08-10 13:11:48 -07:00
..
boards tests: kernel: context: Disable PM for Smartbond 2025-11-20 06:01:14 -05:00
src tests: kernel: Fix changing SoC specific Kconfig 2026-08-10 13:11:48 -07:00
CMakeLists.txt build: bump minimum CMake version to 3.28.0 2026-08-03 15:03:35 -04:00
Kconfig tests: Allow a spurious wake in k_cpu_idle() test 2026-07-07 17:40:55 -04:00
prj.conf tests: kernel: Fix changing SoC specific Kconfig 2026-08-10 13:11:48 -07:00
README.txt tests: kernel: context: refresh legacy README 2026-07-01 17:06:27 -04:00
tests.yaml tests: kernel: rename testcase.yaml to tests.yaml 2026-07-03 19:23:13 -04:00

Title: Context and IRQ APIs

Description:

This test verifies that the kernel CPU, context and interrupt APIs operate
as expected. It is split into three test suites:

1. context
   - test_interrupts exercises irq_lock()/irq_unlock() and irq_offload():
     interrupts stay masked while locked and the offloaded ISR runs in
     interrupt context.
   - test_arch_cpu_irqs_are_enabled checks the arch helper reporting the
     current interrupt-enable state.
   - test_irq_lock_nested verifies that nested irq_lock()/irq_unlock() only
     re-enable interrupts once fully unwound.
   - test_k_can_yield reports whether the current context is allowed to
     yield.
   - test_ctx_thread checks k_current_get() and k_is_in_isr() from both
     thread and ISR context.

2. context_one_cpu (single-CPU only)
   - test_timer_interrupts confirms the tick timer keeps advancing ticks.
   - test_busy_wait validates k_busy_wait() spins for the requested time.
   - test_k_sleep checks that k_sleep() blocks for the requested duration.
   - test_k_yield and test_ctx_coop_thread exercise k_yield() and
     cooperative thread scheduling with k_thread_create().

3. context_cpu_idle
   - test_cpu_idle and test_cpu_idle_atomic verify that k_cpu_idle() and
     k_cpu_atomic_idle() halt the CPU until the next interrupt wakes it.

---------------------------------------------------------------------------

Building and Running:

Build and run with twister, for example on QEMU:

    twister -p qemu_x86 -T tests/kernel/context

Or build and run a single platform directly with west:

    west build -b qemu_x86 tests/kernel/context
    west build -t run

---------------------------------------------------------------------------

Sample Output:

Running TESTSUITE context
===================================================================
START - test_arch_cpu_irqs_are_enabled
 PASS - test_arch_cpu_irqs_are_enabled
===================================================================
START - test_ctx_thread
 PASS - test_ctx_thread
===================================================================
START - test_interrupts
 PASS - test_interrupts
===================================================================
START - test_irq_lock_nested
 PASS - test_irq_lock_nested
===================================================================
START - test_k_can_yield
 PASS - test_k_can_yield
===================================================================
TESTSUITE context succeeded

Running TESTSUITE context_cpu_idle
===================================================================
START - test_cpu_idle
 PASS - test_cpu_idle
===================================================================
START - test_cpu_idle_atomic
 PASS - test_cpu_idle_atomic
===================================================================
TESTSUITE context_cpu_idle succeeded

Running TESTSUITE context_one_cpu
===================================================================
START - test_busy_wait
 PASS - test_busy_wait
===================================================================
START - test_ctx_coop_thread
 PASS - test_ctx_coop_thread
===================================================================
START - test_k_sleep
 PASS - test_k_sleep
===================================================================
START - test_k_yield
 PASS - test_k_yield
===================================================================
START - test_timer_interrupts
 PASS - test_timer_interrupts
===================================================================
TESTSUITE context_one_cpu succeeded