tests: common: move irq_offload test to common
This is a small test that can be easily integrated into the common set of tests we have already. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
d35f1150f3
commit
d0bcf27eab
@ -24,4 +24,5 @@ target_sources(app PRIVATE
|
||||
src/multilib.c
|
||||
src/errno.c
|
||||
src/boot_delay.c
|
||||
src/irq_offload.c
|
||||
)
|
||||
|
||||
@ -4,3 +4,4 @@ CONFIG_LOG=y
|
||||
CONFIG_POLL=y
|
||||
CONFIG_QEMU_TICKLESS_WORKAROUND=y
|
||||
CONFIG_BOOT_DELAY=500
|
||||
CONFIG_IRQ_OFFLOAD=y
|
||||
|
||||
49
tests/kernel/common/src/irq_offload.c
Normal file
49
tests/kernel/common/src/irq_offload.c
Normal file
@ -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 <zephyr.h>
|
||||
#include <ztest.h>
|
||||
#include <kernel_structs.h>
|
||||
#include <irq_offload.h>
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
@ -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),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user