blob: 52648b95faae221bc9aa81c7b18fdb7432ed46f3 [file] [log] [blame]
/*
* 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(z_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");
}