test_irq_offload: unit test for running functions in IRQ context

This is used in many other test cases. However when implementing this
function it's helpful to have a testcase dedicated for it, without
dependencies on other kernel objects.

Change-Id: I66a7cdd0b13712665384d5ad4e79050c82d32e3a
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2016-06-23 13:44:37 -07:00
parent d4a209d484
commit 2ecb9d45d5
6 changed files with 71 additions and 0 deletions

View file

@ -0,0 +1,6 @@
KERNEL_TYPE = nano
BOARD ?= qemu_x86
CONF_FILE = prj.conf
include ${ZEPHYR_BASE}/Makefile.inc

View file

@ -0,0 +1,3 @@
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.

View file

@ -0,0 +1 @@
CONFIG_IRQ_OFFLOAD=y

View file

@ -0,0 +1,3 @@
ccflags-y += -I${srctree}/tests/include
obj-y = main.o

View file

@ -0,0 +1,55 @@
/*
* Copyright (c) 2015 Wind River Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <zephyr.h>
#include <tc_util.h>
#include <nano_private.h>
#include <irq_offload.h>
volatile uint32_t sentinel;
#define SENTINEL_VALUE 0xDEADBEEF
void offload_function(void *param)
{
uint32_t x = (uint32_t)param;
TC_PRINT("offload_function running\n");
/* Make sure we're in IRQ context */
if (!_IS_IN_ISR()) {
TC_PRINT("Not in IRQ context!\n");
return;
}
sentinel = x;
}
void main(void)
{
int rv = TC_PASS;
TC_START("test_irq_offload");
irq_offload(offload_function, (void *)SENTINEL_VALUE);
if (sentinel != SENTINEL_VALUE) {
TC_PRINT("irq_offload() didn't work properly\n");
rv = TC_FAIL;
}
TC_END_RESULT(rv);
TC_END_REPORT(rv);
}

View file

@ -0,0 +1,3 @@
[test]
tags = core
kernel = nano