提交 ed863e90 编写于 作者: Z zhushengle

fix: 修复任务栈对齐问题及补充posix和cmsis测试用例

Signed-off-by: Nzhushengle <zhushengle@huawei.com>
Change-Id: I2075f1821c46aea17bbec498f533905d720621c4
上级 36887d46
......@@ -668,7 +668,6 @@ LITE_OS_SEC_TEXT_INIT STATIC_INLINE UINT32 OsTaskInitParamCheck(TSK_INIT_PARAM_S
if (taskInitParam->uwStackSize == 0) {
taskInitParam->uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
}
taskInitParam->uwStackSize = ALIGN(taskInitParam->uwStackSize, OS_TASK_STACK_ADDR_ALIGN);
if (taskInitParam->uwStackSize < LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE) {
return LOS_ERRNO_TSK_STKSZ_TOO_SMALL;
......@@ -704,6 +703,7 @@ STATIC UINT32 OsNewTaskInit(LosTaskCB *taskCB, TSK_INIT_PARAM_S *taskInitParam)
}
if (taskInitParam->stackAddr == (UINTPTR)NULL) {
taskCB->stackSize = ALIGN(taskInitParam->uwStackSize, OS_TASK_STACK_ADDR_ALIGN);
#if (LOSCFG_EXC_HARDWARE_STACK_PROTECTION == 1)
UINT32 stackSize = taskCB->stackSize + OS_TASK_STACK_PROTECT_SIZE;
UINTPTR stackPtr = (UINTPTR)LOS_MemAllocAlign(OS_TASK_STACK_ADDR, stackSize, OS_TASK_STACK_PROTECT_SIZE);
......@@ -718,7 +718,8 @@ STATIC UINT32 OsNewTaskInit(LosTaskCB *taskCB, TSK_INIT_PARAM_S *taskInitParam)
taskCB->taskStatus |= OS_TASK_FLAG_STACK_FREE;
} else {
taskCB->topOfStack = LOS_Align(taskInitParam->stackAddr, LOSCFG_STACK_POINT_ALIGN_SIZE);
taskCB->stackSize = ALIGN(taskCB->stackSize, OS_TASK_STACK_ADDR_ALIGN);
taskCB->stackSize = taskInitParam->uwStackSize - (taskCB->topOfStack - taskInitParam->stackAddr);
taskCB->stackSize = TRUNCATE(taskCB->stackSize, OS_TASK_STACK_ADDR_ALIGN);
}
/* initialize the task stack, write magic num to stack top */
......
......@@ -51,6 +51,7 @@ kernel_module("test_init") {
group("testsuites") {
deps = [
":test_init",
"sample/cmsis:test_cmsis",
"sample/kernel/atomic:test_atomic",
"sample/kernel/event:test_event",
"sample/kernel/hwi:test_hwi",
......@@ -61,6 +62,7 @@ group("testsuites") {
"sample/kernel/sem:test_sem",
"sample/kernel/swtmr:test_swtmr",
"sample/kernel/task:test_task",
"sample/posix:test_posix",
]
if (defined(LOSCFG_DYNLINK)) {
deps += [ "sample/kernel/dynlink:test_dynlink" ]
......
......@@ -87,12 +87,17 @@ extern "C" {
#define LOS_KERNEL_MEM_TEST 1
#define LOS_KERNEL_DYNLINK_TEST 0
#define LOS_KERNEL_TICKLESS_TEST 0
#if (LOSCFG_KERNEL_PM == 1)
#define LOS_KERNEL_PM_TEST 1
#else
#define LOS_KERNEL_PM_TEST 0
#endif
#define LOS_KERNEL_LMS_TEST 0
#define LOS_KERNEL_LMK_TEST 0
#define LOS_KERNEL_SIGNAL_TEST 0
#define LITEOS_CMSIS_TEST 0
#define LOS_POSIX_TEST 1
#define LOS_CMSIS_TEST 1
#define LOS_CMSIS2_CORE_TASK_TEST 0
#define LOS_CMSIS2_IPC_MUX_TEST 0
#define LOS_CMSIS2_IPC_SEM_TEST 0
......@@ -349,6 +354,10 @@ extern VOID ItSuiteLosPm(void);
extern VOID ItSuiteLosLmk(void);
extern VOID ItSuiteLosSignal(void);
extern int PthreadFuncTestSuite(void);
extern void CmsisFuncTestSuite(void);
extern VOID ItSuite_Cmsis_Lostask(void);
extern VOID ItSuite_Cmsis_Lostask_add(void);
extern VOID ItSuite_CMSIS_Losmsg(void);
......
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
static_library("test_cmsis") {
sources = [ "cmsis_func_test.c" ]
configs += [ "//kernel/liteos_m/testsuites:include" ]
}
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <securec.h>
#include "osTest.h"
#include "cmsis_os.h"
#define TEST_STR(func) ItLos##func
#define TEST_TO_STR(x) #x
#define TEST_HEAD_TO_STR(x) TEST_TO_STR(x)
#define ADD_TEST_CASE(func) \
TEST_ADD_CASE(TEST_HEAD_TO_STR(TEST_STR(func)), func, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION)
#define Function 0
#define MediumTest 0
#define Level1 0
#define LITE_TEST_CASE(module, function, flag) static int function(void)
static VOID CmsisStackFunc01(void)
{
g_testCount++;
return;
}
/**
* @tc.number : SUB_KERNEL_PTHREAD_OPERATION_001
* @tc.name : event operation for join
* @tc.desc : [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(CmsisFuncTestSuite, TestCmsis001, Function | MediumTest | Level1)
{
osThreadId_t threadId;
osThreadAttr_t attr = {0};
g_testCount = 0;
void *stackAddr = malloc(OS_TSK_TEST_STACK_SIZE);
ICUNIT_ASSERT_NOT_EQUAL(stackAddr, NULL, stackAddr);
attr.stack_mem = stackAddr;
attr.stack_size = OS_TSK_TEST_STACK_SIZE;
attr.priority = osPriorityNormal;
attr.attr_bits = osThreadDetached;
threadId = osThreadNew((osThreadFunc_t)CmsisStackFunc01, NULL, &attr);
ICUNIT_GOTO_NOT_EQUAL(threadId, 0, threadId, EXIT);
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
EXIT:
free(stackAddr);
return LOS_OK;
};
void CmsisFuncTestSuite(void)
{
ADD_TEST_CASE(TestCmsis001);
}
......@@ -46,7 +46,7 @@ static UINT32 TestCase(VOID)
g_testCount = 0;
osTaskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskDeatchf01;
osTaskInitParam.uwStackSize = OS_TSK_TEST_STACK_SIZE;
osTaskInitParam.uwStackSize = 0x1003; /* 0x1003: The size is not aligned */
osTaskInitParam.pcName = "deatch";
osTaskInitParam.usTaskPrio = TASK_PRIO_TEST - 5; /* 5: Relatively high priority */
osTaskInitParam.uwResved = LOS_TASK_ATTR_JOINABLE;
......
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
static_library("test_posix") {
sources = [ "pthread_func_test.c" ]
configs += [ "//kernel/liteos_m/testsuites:include" ]
}
此差异已折叠。
......@@ -214,15 +214,22 @@ void TestCmsis2(void)
VOID TestTaskEntry()
{
UINT32 ret;
PRINTF("\t\n --- Test Start --- \n\n");
ICunitInit();
TestKernel();
#if (CMSIS_OS_VER == 1)
PRINTF("\n --- cmsis 1 unsupport--- \n\n");
#elif (CMSIS_OS_VER == 2)
TestCmsis2();
#if (LOS_POSIX_TEST == 1)
ret = PthreadFuncTestSuite();
if (ret != 0) {
PRINTF("PthreadFuncTestSuite start failed! errno: %u\n", ret);
return;
}
#endif
#if (LOS_CMSIS_TEST == 1)
CmsisFuncTestSuite();
#endif
/* The log is used for testing entrance guard, please do not make any changes. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册