diff --git a/tests/kernel/common/CMakeLists.txt b/tests/kernel/common/CMakeLists.txt index ad1d8b4a02f..cbe224ea2d9 100644 --- a/tests/kernel/common/CMakeLists.txt +++ b/tests/kernel/common/CMakeLists.txt @@ -24,4 +24,5 @@ target_sources(app PRIVATE src/multilib.c src/errno.c src/boot_delay.c + src/irq_offload.c ) diff --git a/tests/kernel/common/prj.conf b/tests/kernel/common/prj.conf index 11ea55482fe..741af5fe3b0 100644 --- a/tests/kernel/common/prj.conf +++ b/tests/kernel/common/prj.conf @@ -4,3 +4,4 @@ CONFIG_LOG=y CONFIG_POLL=y CONFIG_QEMU_TICKLESS_WORKAROUND=y CONFIG_BOOT_DELAY=500 +CONFIG_IRQ_OFFLOAD=y diff --git a/tests/kernel/common/src/irq_offload.c b/tests/kernel/common/src/irq_offload.c new file mode 100644 index 00000000000..8ef25437040 --- /dev/null +++ b/tests/kernel/common/src/irq_offload.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2017 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file + * + * This test case verifies the correctness of irq_offload(), an important + * routine used in many other test cases for running a function in interrupt + * context, on the IRQ stack. + * + */ +#include +#include +#include +#include + +volatile u32_t sentinel; +#define SENTINEL_VALUE 0xDEADBEEF + +static void offload_function(void *param) +{ + u32_t x = (u32_t)param; + + /* Make sure we're in IRQ context */ + zassert_true(_is_in_isr(), "Not in IRQ context!"); + + sentinel = x; +} + +/** + * @brief Verify thread context + * + * @ingroup kernel_interrupt_tests + * + * @details Check whether offloaded running function is in interrupt + * context, on the IRQ stack or not. + */ +void test_irq_offload(void) +{ + /**TESTPOINT: Offload to IRQ context*/ + irq_offload(offload_function, (void *)SENTINEL_VALUE); + + zassert_equal(sentinel, SENTINEL_VALUE, + "irq_offload() didn't work properly"); +} + diff --git a/tests/kernel/common/src/main.c b/tests/kernel/common/src/main.c index 2e62704efe4..874f393a279 100644 --- a/tests/kernel/common/src/main.c +++ b/tests/kernel/common/src/main.c @@ -22,6 +22,7 @@ extern void test_clock_uptime(void); extern void test_multilib(void); extern void test_thread_context(void); extern void test_verify_bootdelay(void); +extern void test_irq_offload(void); /** * @defgroup kernel_common_tests Common Tests @@ -71,6 +72,7 @@ void test_main(void) { ztest_test_suite(common, ztest_unit_test(test_verify_bootdelay), + ztest_unit_test(test_irq_offload), ztest_unit_test(test_byteorder_memcpy_swap), ztest_unit_test(test_byteorder_mem_swap), ztest_unit_test(test_atomic),