samples/microkernel: add test for private tasks

This adds unit test for microkernel private tasks.
The code piggybacks to the public task test (by
including the same source file), so any updates to
the test will be applied to both.

Note that the prj.mdef are different for both tests, since
the private tasks test move the tasks inside source
code. So, both mdef files will need to be updated at
the same time.

Change-Id: I2890f70be460c0e45208ce03d6e7897d2662f6f0
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2015-07-24 11:21:35 -07:00 committed by Anas Nashif
parent 2bc5880d85
commit 62077917b6
10 changed files with 100 additions and 0 deletions

View File

@ -70,6 +70,16 @@ static int helperData;
static volatile int mainTaskNotReady = 0;
#ifdef TEST_PRIV_TASKS
/* Note this is in reverse order of what is defined under
* test_task/prj.mdef. This is due to compiler filling linker
* section like a stack. This is to preserve the same order
* in memory as test_task.
*/
DEFINE_TASK(RT_TASKID, 10, RegressionTask, 2048, EXE);
DEFINE_TASK(HT_TASKID, 20, HelperTask, 2048, EXE);
#endif
/**
*
* @brief ISR handler to call isr_task_id_get() and isr_task_priority_get()

View File

@ -0,0 +1,9 @@
MDEF_FILE = prj.mdef
KERNEL_TYPE = micro
PLATFORM_CONFIG ?= basic_atom
CONF_FILE = prj_$(ARCH).conf
# Enable testing for private microkernel task objects
CFLAGS = -DTEST_PRIV_TASKS
include ${ZEPHYR_BASE}/Makefile.inc

View File

@ -0,0 +1,46 @@
Title: test_task_priv
Description:
This test verifies that the microkernel task APIs operate as expected. This
also verifies the mechanism to define private task objects and their usage.
--------------------------------------------------------------------------------
Building and Running Project:
This microkernel 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:
tc_start() - Test Microkernel Task API
===================================================================
Microkernel objects initialized
Testing isr_task_id_get() and isr_task_priority_get()
Testing task_id_get() and task_priority_get()
Testing task_priority_set()
Testing task_sleep()
Testing task_yield()
Testing task_suspend() and task_resume()
===================================================================
PASS - RegressionTask.
===================================================================
PROJECT EXECUTION SUCCESSFUL

View File

@ -0,0 +1,17 @@
% Application : test microkernel task APIs
% Please keep this in-sync with ../test_task/prj.mdef
% except those specified below
% TASK HT_TASKID and RT_TASKID are defined within
% the source file, so keep them commented out.
%
% TASK NAME PRIO ENTRY STACK GROUPS
% ==================================================
% TASK HT_TASKID 20 HelperTask 2048 [EXE]
% TASK RT_TASKID 10 RegressionTask 2048 [EXE]
% SEMA NAME
% ===========
SEMA HT_SEM
SEMA RT_SEM

View File

@ -0,0 +1,2 @@
CONFIG_NUM_TASK_PRIORITIES=32
CONFIG_NUM_IRQS=2

View File

@ -0,0 +1,7 @@
CONFIG_NUM_TASK_PRIORITIES=32
# Let stack canaries use non-random number generator.
# This option is NOT to be used in production code.
CONFIG_DRV_RANDOM=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NUM_DYNAMIC_STUBS=2

View File

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

View File

@ -0,0 +1 @@
#include "../../test_task/src/task.c"

View File

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

View File

@ -51,6 +51,7 @@ microkernel/test/test_sema_priv <uq> basic_cortex_m3! fsl_frdm_k64f
microkernel/test/test_sprintf <u> basic_cortex_m3! fsl_frdm_k64f
microkernel/test/test_stackprot <u> basic_cortex_m3! fsl_frdm_k64f
microkernel/test/test_task <uq> basic_cortex_m3! fsl_frdm_k64f
microkernel/test/test_task_priv <uq> basic_cortex_m3! fsl_frdm_k64f
microkernel/test/test_task_irq <u> basic_cortex_m3! fsl_frdm_k64f
microkernel/test/test_timer <uq> basic_cortex_m3! fsl_frdm_k64f
microkernel/test/test_xip <uq> basic_cortex_m3! fsl_frdm_k64f
@ -74,6 +75,7 @@ microkernel/test/test_sprintf <u> basic_minuteia! basic_atom! galileo
microkernel/test/test_stackprot <u> basic_minuteia! basic_atom! galileo
microkernel/test/test_static_idt <uq> basic_minuteia! basic_atom! galileo
microkernel/test/test_task <uq> basic_minuteia! basic_atom! galileo
microkernel/test/test_task_priv <uq> basic_minuteia! basic_atom! galileo
microkernel/test/test_task_irq <u> basic_minuteia! basic_atom! galileo
microkernel/test/test_tickless <uq> basic_minuteia! basic_atom! galileo
microkernel/test/test_timer <uq> basic_minuteia! basic_atom! galileo