tests: add systhreads test case

this commit check the priority of 2 system threads - main and idle

Change-Id: Ie57e7fdab3d15c0b69d85ed6282bfa6aa04133b4
Signed-off-by: jing wang <jing.j.wang@intel.com>
This commit is contained in:
jing wang 2016-12-27 16:06:58 +08:00 committed by Anas Nashif
commit 4e5fa0ede2
8 changed files with 109 additions and 0 deletions

View file

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

View file

@ -0,0 +1,12 @@
$make qemu
Running test suite test_systhreads
tc_start() - test_systhreads_main
===================================================================
PASS - test_systhreads_main.
tc_start() - test_systhreads_idle
===================================================================
PASS - test_systhreads_idle.
===================================================================
PROJECT EXECUTION SUCCESSFUL

View file

@ -0,0 +1,5 @@
CONFIG_ZTEST=y
CONFIG_SYS_POWER_MANAGEMENT=y
CONFIG_SYS_POWER_LOW_POWER_STATE=y
CONFIG_TICKLESS_IDLE=y
CONFIG_LEGACY_KERNEL=n

View file

@ -0,0 +1,3 @@
include $(ZEPHYR_BASE)/tests/Makefile.test
obj-y = main.o test_systhreads.o

View file

@ -0,0 +1,30 @@
/*
* Copyright (c) 2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @addtogroup t_kernel_threads
* @{
* @defgroup t_systhreads test_systhreads
* @brief TestPurpose: verify 2 system threads - main thread and idle thread
* @}
*/
#include <ztest.h>
#include "test_systhreads.h"
/* test case main entry */
void test_main(void *p1, void *p2, void *p3)
{
ARG_UNUSED(p1);
ARG_UNUSED(p2);
ARG_UNUSED(p3);
test_systhreads_setup();
ztest_test_suite(test_systhreads,
ztest_unit_test(test_systhreads_main),
ztest_unit_test(test_systhreads_idle));
ztest_run_test_suite(test_systhreads);
}

View file

@ -0,0 +1,37 @@
/*
* Copyright (c) 2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <ztest.h>
static int main_prio;
/* power hook functions if support */
int _sys_soc_suspend(int32_t ticks)
{
/** TESTPOINT: check idle thread priority */
assert_true(k_thread_priority_get(k_current_get()) ==
K_IDLE_PRIO, NULL);
return 0;
}
/* test cases */
void test_systhreads_setup(void)
{
main_prio = k_thread_priority_get(k_current_get());
}
void test_systhreads_main(void)
{
assert_true(main_prio == CONFIG_MAIN_THREAD_PRIORITY, NULL);
}
void test_systhreads_idle(void)
{
k_sleep(100);
/** TESTPOINT: check working thread priority should */
assert_true(k_thread_priority_get(k_current_get()) <
K_IDLE_PRIO, NULL);
}

View file

@ -0,0 +1,14 @@
/*
* Copyright (c) 2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __TEST_SYSTHREADS_H__
#define __TEST_SYSTHREADS_H__
void test_systhreads_setup(void);
void test_systhreads_main(void);
void test_systhreads_idle(void);
#endif /* __TEST_SYSTHREADS_H__ */

View file

@ -0,0 +1,4 @@
[test]
tags = kernel
# tickless is not supported on nios2 and riscv-machine
arch_exclude = nios2 riscv32