tests/kernel: verify RUNTIME_NMI at runtime

This patch introduces a test that verifies the behavior of
CONFIG_RUNTIME_NMI at runtime.

The test is meant to be only for ARM Cortex-M targets.

Change-Id: I805a88e67fe47d396ac9e29e1275e5452a4b8a36
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
This commit is contained in:
Vincenzo Frascino 2016-11-30 20:53:50 +00:00 committed by Anas Nashif
commit fc1071d91e
6 changed files with 107 additions and 0 deletions

View file

@ -0,0 +1,4 @@
BOARD ?= qemu_cortex_m3
CONF_FILE = prj.conf
include $(ZEPHYR_BASE)/Makefile.inc

View file

@ -0,0 +1,45 @@
Title: Test to verify the behavior of CONFIG_RUNTIME_NMI at runtime (ARM Only)
Description:
This test verifies the behavior of CONFIG_RUNTIME_NMI at runtime. Only for
ARM Cortex-M targets.
---------------------------------------------------------------------------
Building and Running Project:
This project outputs to the console. It can be built and executed on QEMU as
follows:
make qemu
---------------------------------------------------------------------------
Troubleshooting:
Problems caused by out-dated project information can be addressed by
issuing one of the following commands then rebuilding the project:
make clean # discard results of previous builds
# but keep existing configuration info
or
make pristine # discard results of previous builds
# and restore pre-defined configuration info
---------------------------------------------------------------------------
Sample Output:
Trigger NMI in 10s: 0 s
Trigger NMI in 10s: 1 s
Trigger NMI in 10s: 2 s
Trigger NMI in 10s: 3 s
Trigger NMI in 10s: 4 s
Trigger NMI in 10s: 5 s
Trigger NMI in 10s: 6 s
Trigger NMI in 10s: 7 s
Trigger NMI in 10s: 8 s
Trigger NMI in 10s: 9 s
NMI received (test_handler_isr)! Rebooting...
...

View file

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

View file

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

View file

@ -0,0 +1,51 @@
/*
* Copyright (c) 2016 Linaro Limited
*
* 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.
*/
/**
* @brief Test to verify the behavior of CONFIG_RUNTIME_NMI at runtime.
*/
#include <zephyr.h>
#include <misc/printk.h>
#include <misc/reboot.h>
#include <tc_util.h>
extern void _NmiHandlerSet(void (*pHandler)(void));
static void nmi_test_isr(void)
{
printk("NMI received (test_handler_isr)! Rebooting...\n");
/* ISR triggered correctly: test passed! */
TC_END_RESULT(TC_PASS);
TC_END_REPORT(TC_PASS);
}
void main(void)
{
uint32_t i = 0;
/* Configure the NMI isr */
_NmiHandlerSet(nmi_test_isr);
for (i = 0; i < 10; i++) {
printk("Trigger NMI in 10s: %d s\n", i);
k_sleep(1000);
}
/* Trigger NMI: Should fire immediately */
_ScbNmiPend();
}

View file

@ -0,0 +1,3 @@
[test]
tags = core bat_commit
arch_whitelist = arm