add testsuites
Change-Id: Ice1193d1ae7f2e0d12a2a38a306a6399407f5037
This commit is contained in:
21
testsuites/kernel/sample/kernel_extend/cpup/BUILD.gn
Normal file
21
testsuites/kernel/sample/kernel_extend/cpup/BUILD.gn
Normal file
@@ -0,0 +1,21 @@
|
||||
static_library("test_cpup") {
|
||||
|
||||
sources = [
|
||||
"It_extend_cpup.c",
|
||||
]
|
||||
|
||||
if (LOSCFG_TEST_SMOKE) {
|
||||
sources += [
|
||||
"smoke/It_extend_cpup_001.c",
|
||||
"smoke/It_extend_cpup_002.c",
|
||||
]
|
||||
}
|
||||
|
||||
include_dirs = [
|
||||
"../../../include/",
|
||||
"./",
|
||||
"../../../../kernel/extended/include",
|
||||
]
|
||||
|
||||
cflags = [ "-Wno-error" ]
|
||||
}
|
||||
117
testsuites/kernel/sample/kernel_extend/cpup/It_extend_cpup.c
Normal file
117
testsuites/kernel/sample/kernel_extend/cpup/It_extend_cpup.c
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
UINT32 GetNopCount(void)
|
||||
{
|
||||
return LOS_CyclePerTickGet();
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||
|
||||
CPUP_INFO_S g_testPstHwiCpupAll[OS_HWI_MAX_NUM];
|
||||
CPUP_INFO_S g_testPstHwiCpup10s[OS_HWI_MAX_NUM];
|
||||
CPUP_INFO_S g_testPstHwiCpup1s[OS_HWI_MAX_NUM];
|
||||
|
||||
UINT32 TestGetSingleHwiCpup(UINT32 hwi, UINT32 mode)
|
||||
{
|
||||
UINT32 size;
|
||||
UINT32 tempHwi;
|
||||
if (hwi < 0 || hwi > OS_HWI_MAX_NUM) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
size = sizeof(CPUP_INFO_S) * LOS_GetSystemHwiMaximum();
|
||||
switch (mode) {
|
||||
case CPUP_LAST_ONE_SECONDS:
|
||||
(VOID)memset_s((VOID *)g_testPstHwiCpup1s, size, 0, size);
|
||||
(VOID)LOS_GetAllIrqCpuUsage(CPUP_LAST_ONE_SECONDS, g_testPstHwiCpup1s, size);
|
||||
tempHwi = g_testPstHwiCpup1s[hwi].usage;
|
||||
break;
|
||||
case CPUP_LAST_TEN_SECONDS:
|
||||
(VOID)memset_s((VOID *)g_testPstHwiCpup10s, size, 0, size);
|
||||
(VOID)LOS_GetAllIrqCpuUsage(CPUP_LAST_TEN_SECONDS, g_testPstHwiCpup10s, size);
|
||||
tempHwi = g_testPstHwiCpup10s[hwi].usage;
|
||||
break;
|
||||
case CPUP_ALL_TIME:
|
||||
/* fall-through */
|
||||
default:
|
||||
(VOID)memset_s((VOID *)g_testPstHwiCpupAll, size, 0, size);
|
||||
(VOID)LOS_GetAllIrqCpuUsage(CPUP_ALL_TIME, g_testPstHwiCpupAll, size);
|
||||
tempHwi = g_testPstHwiCpupAll[hwi].usage;
|
||||
break;
|
||||
}
|
||||
return tempHwi;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
VOID ItSuiteExtendCpup(VOID)
|
||||
{
|
||||
#if defined(LOSCFG_TEST_SMOKE)
|
||||
ItExtendCpup001();
|
||||
ItExtendCpup002();
|
||||
#endif
|
||||
|
||||
#if defined(LOSCFG_TEST_FULL)
|
||||
ItExtendCpup003();
|
||||
ItExtendCpup004();
|
||||
ItExtendCpup005();
|
||||
ItExtendCpup006();
|
||||
ItExtendCpup007();
|
||||
ItExtendCpup008();
|
||||
ItExtendCpup011();
|
||||
ItExtendCpup012();
|
||||
#endif
|
||||
|
||||
#if defined(LOSCFG_TEST_LLT)
|
||||
LltExtendCpup003();
|
||||
ItExtendCpup009();
|
||||
ItExtendCpup010();
|
||||
#endif
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
ItSmpExtendCpup001();
|
||||
ItSmpExtendCpup002();
|
||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||
ItSmpExtendCpup003();
|
||||
ItSmpExtendCpup004();
|
||||
#endif
|
||||
ItSmpExtendCpup005();
|
||||
ItSmpExtendCpup007();
|
||||
ItSmpExtendCpup008();
|
||||
ItSmpExtendCpup009();
|
||||
ItSmpExtendCpup010();
|
||||
ItSmpExtendCpup011();
|
||||
ItSmpExtendCpup012();
|
||||
#endif
|
||||
}
|
||||
142
testsuites/kernel/sample/kernel_extend/cpup/It_extend_cpup.h
Normal file
142
testsuites/kernel/sample/kernel_extend/cpup/It_extend_cpup.h
Normal file
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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.
|
||||
*/
|
||||
|
||||
#ifndef IT_LOS_CPUP_H
|
||||
#define IT_LOS_CPUP_H
|
||||
|
||||
#include "los_cpup_pri.h"
|
||||
#include "los_cpup.h"
|
||||
#include "los_sys.h"
|
||||
#include "los_task.h"
|
||||
#include "osTest.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
#define CPU_USE_MODE1 1
|
||||
#define CPU_USE_MODE0 0
|
||||
#define CPU_USE_MIN 0
|
||||
#define TASK_STATUS_UNDETACHED 0
|
||||
|
||||
#define CPUP_TEST_TOLERANT 50
|
||||
#define CPUP_BACKWARD 2
|
||||
|
||||
#define ICUNIT_ASSERT_PROCESS_CPUP_USAGE(usage, lable) \
|
||||
do { \
|
||||
UINT32 ret_ = LOS_NOK; \
|
||||
if (((usage) > LOS_CPUP_PRECISION) || ((usage) < CPU_USE_MIN)) { \
|
||||
ret_ = LOS_OK; \
|
||||
} else { \
|
||||
ret_ = usage; \
|
||||
} \
|
||||
ICUNIT_GOTO_EQUAL(ret_, LOS_OK, ret_, lable); \
|
||||
} while (0)
|
||||
|
||||
#define ICUNIT_ASSERT_SINGLE_CPUP_USAGE(usage, lable) \
|
||||
do { \
|
||||
UINT32 ret_ = LOS_NOK; \
|
||||
if (((usage) > LOS_CPUP_SINGLE_CORE_PRECISION) || ((usage) < CPU_USE_MIN)) { \
|
||||
ret_ = LOS_OK; \
|
||||
} else { \
|
||||
ret_ = usage; \
|
||||
} \
|
||||
ICUNIT_GOTO_EQUAL(ret_, LOS_OK, ret_, lable); \
|
||||
} while (0)
|
||||
|
||||
extern UINT32 g_cpuTestTaskID;
|
||||
extern UINT32 g_testTaskID01;
|
||||
extern UINT32 g_testTaskID02;
|
||||
extern UINT32 g_testTaskID03;
|
||||
extern UINT32 g_cpupTestCount;
|
||||
extern VOID ItSuiteExtendCpup(VOID);
|
||||
extern UINT32 TimeClkRead(VOID);
|
||||
extern LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdCpup(INT32 argc, CHAR **argv);
|
||||
extern LITE_OS_SEC_TEXT_MINOR VOID OsTaskCycleEnd(VOID);
|
||||
extern LITE_OS_SEC_TEXT_MINOR UINT64 OsGetCpuCycle(VOID);
|
||||
|
||||
extern UINT32 GetNopCount(void);
|
||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||
extern UINT32 TestGetSingleHwiCpup(UINT32 hwi, UINT32 mode);
|
||||
#endif
|
||||
|
||||
#if defined(LOSCFG_TEST_SMOKE)
|
||||
VOID ItExtendCpup001(VOID);
|
||||
VOID ItExtendCpup002(VOID);
|
||||
#endif
|
||||
|
||||
#if defined(LOSCFG_TEST_FULL)
|
||||
VOID ItExtendCpup003(VOID);
|
||||
VOID ItExtendCpup004(VOID);
|
||||
VOID ItExtendCpup005(VOID);
|
||||
VOID ItExtendCpup006(VOID);
|
||||
VOID ItExtendCpup007(VOID);
|
||||
VOID ItExtendCpup008(VOID);
|
||||
VOID ItExtendCpup011(VOID);
|
||||
VOID ItExtendCpup012(VOID);
|
||||
#endif
|
||||
|
||||
#if defined(LOSCFG_TEST_LLT)
|
||||
VOID LLT_EXTEND_CPUP_001(VOID);
|
||||
VOID LLT_EXTEND_CPUP_002(VOID);
|
||||
VOID LltExtendCpup003(VOID);
|
||||
VOID LLT_EXTEND_CPUP_006(VOID);
|
||||
VOID LLT_EXTEND_CPUP_007(VOID);
|
||||
VOID ItExtendCpup009(VOID);
|
||||
VOID ItExtendCpup010(VOID);
|
||||
#endif
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
VOID ItSmpExtendCpup001(VOID);
|
||||
VOID ItSmpExtendCpup002(VOID);
|
||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||
VOID ItSmpExtendCpup003(VOID);
|
||||
VOID ItSmpExtendCpup004(VOID);
|
||||
#endif
|
||||
VOID ItSmpExtendCpup005(VOID);
|
||||
VOID ItSmpExtendCpup006(VOID);
|
||||
VOID ItSmpExtendCpup007(VOID);
|
||||
VOID ItSmpExtendCpup008(VOID);
|
||||
VOID ItSmpExtendCpup009(VOID);
|
||||
VOID ItSmpExtendCpup010(VOID);
|
||||
VOID ItSmpExtendCpup011(VOID);
|
||||
VOID ItSmpExtendCpup012(VOID);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
#endif
|
||||
40
testsuites/kernel/sample/kernel_extend/cpup/Makefile
Normal file
40
testsuites/kernel/sample/kernel_extend/cpup/Makefile
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
include $(LITEOSTESTTOPDIR)/config.mk
|
||||
|
||||
MODULE_NAME := cpuptest
|
||||
|
||||
LOCAL_INCLUDE := \
|
||||
-I $(LITEOSTESTTOPDIR)/kernel/include \
|
||||
-I $(LITEOSTESTTOPDIR)/kernel/sample/kernel_extend/cpup \
|
||||
-I $(LITEOSTOPDIR)/kernel/extended/include/
|
||||
|
||||
SRC_MODULES := .
|
||||
|
||||
ifeq ($(LOSCFG_KERNEL_SMP), y)
|
||||
SMP_MODULES := smp
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_TEST_LLT), y)
|
||||
LLT_MODULES := llt
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_TEST_PRESSURE), y)
|
||||
PRESSURE_MODULES := pressure
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_TEST_SMOKE), y)
|
||||
SMOKE_MODULES := smoke
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_TEST_FULL), y)
|
||||
FULL_MODULES := full
|
||||
endif
|
||||
|
||||
LOCAL_MODULES := $(SRC_MODULES) $(SMOKE_MODULES) $(FULL_MODULES) $(SMP_MODULES) $(LLT_MODULES)
|
||||
|
||||
LOCAL_SRCS := $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.c))
|
||||
LOCAL_CHS := $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.h))
|
||||
|
||||
LOCAL_FLAGS := $(LOCAL_INCLUDE) -Wno-error
|
||||
|
||||
include $(MODULE)
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
static UINT32 TaskF02(VOID)
|
||||
{
|
||||
UINT32 cpupUse, ret;
|
||||
g_testTaskID02 = LOS_GetCurrProcessID();
|
||||
|
||||
ret = LOS_SetProcessPriority(g_testTaskID02, TASK_PRIO_TEST - 1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 2, g_cpupTestCount); // 2, Here, assert that g_cpupTestCount is equal to the expected value.
|
||||
g_cpupTestCount++;
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(g_testTaskID01, CPUP_ALL_TIME);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(g_testTaskID02, CPUP_ALL_TIME);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
LOS_TaskDelay(3); // 3, set delay time.
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 4, g_cpupTestCount); // 4, Here, assert that g_cpupTestCount is equal to the expected value.
|
||||
g_cpupTestCount++;
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static UINT32 TaskF01(VOID)
|
||||
{
|
||||
UINT32 cpupUse, ret;
|
||||
g_testTaskID01 = LOS_GetCurrProcessID();
|
||||
|
||||
// 2, used to calculate the task priority.
|
||||
ret = LOS_SetProcessPriority(g_testTaskID01, TASK_PRIO_TEST - 2);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 0, g_cpupTestCount);
|
||||
g_cpupTestCount++;
|
||||
|
||||
cpupUse = LOS_HistorySysCpuUsage(CPUP_ALL_TIME);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
LOS_TaskDelay(4); // 4, set delay time.
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 3, g_cpupTestCount); // 3, Here, assert that g_cpupTestCount is equal to the expected value.
|
||||
g_cpupTestCount++;
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret, cpupUse;
|
||||
INT32 pid1;
|
||||
|
||||
g_cpupTestCount = 0;
|
||||
INT32 pid = LOS_Fork(0, "TestCpupTsk1", TaskF01, TASK_STACK_SIZE_TEST);
|
||||
if (pid < 0) {
|
||||
ICUNIT_ASSERT_EQUAL(1, LOS_OK, 1);
|
||||
}
|
||||
|
||||
LOS_TaskDelay(2); // 2, set delay time.
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 1, g_cpupTestCount);
|
||||
g_cpupTestCount++;
|
||||
|
||||
pid1 = LOS_Fork(0, "TestCpupTsk2", TaskF02, TASK_STACK_SIZE_TEST);
|
||||
if (pid1 < 0) {
|
||||
ICUNIT_ASSERT_EQUAL(1, LOS_OK, 1);
|
||||
}
|
||||
|
||||
LOS_TaskDelay(2); // 2, set delay time.
|
||||
|
||||
cpupUse = LOS_HistorySysCpuUsage(CPUP_ALL_TIME);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
cpupUse = LOS_HistorySysCpuUsage(CPU_USE_MODE1);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
LOS_TaskDelay(3); // 3, set delay time.
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 5, g_cpupTestCount); // 5, Here, assert that g_cpupTestCount is equal to the expected value.
|
||||
|
||||
(VOID)LOS_Wait(pid, NULL, 0, NULL);
|
||||
(VOID)LOS_Wait(pid1, NULL, 0, NULL);
|
||||
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
VOID ItExtendCpup003(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItExtendCpup003", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
static UINT32 TaskF02(VOID)
|
||||
{
|
||||
UINT32 cpupUse, ret;
|
||||
ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 2, g_cpupTestCount); // 2, Here, assert that g_cpupTestCount is equal to the expected value.
|
||||
g_cpupTestCount++;
|
||||
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_ALL_TIME);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ret = LOS_TaskDelete(g_testTaskID02);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
ret = LOS_TaskDelete(g_testTaskID02);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static UINT32 TaskF01(VOID)
|
||||
{
|
||||
UINT32 ret, cpupUse;
|
||||
TSK_INIT_PARAM_S task1 = { 0 };
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "TestCpupTsk2";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
|
||||
task1.uwResved = TASK_STATUS_UNDETACHED;
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 0, g_cpupTestCount);
|
||||
g_cpupTestCount++;
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID02, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 1, g_cpupTestCount);
|
||||
g_cpupTestCount++;
|
||||
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_ALL_TIME);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
return ret;
|
||||
}
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret, cpupUse;
|
||||
TSK_INIT_PARAM_S task1 = { 0 };
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "TestCpupTsk1";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
|
||||
task1.uwResved = TASK_STATUS_UNDETACHED;
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
g_cpupTestCount = 0;
|
||||
|
||||
cpupUse = LOS_HistorySysCpuUsage(CPUP_ALL_TIME);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 3, g_cpupTestCount); // 3, Here, assert that g_cpupTestCount is equal to the expected value.
|
||||
g_cpupTestCount++;
|
||||
|
||||
ret = LOS_TaskDelete(g_testTaskID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
VOID ItExtendCpup004(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItExtendCpup004", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
static UINT32 TaskF01(VOID)
|
||||
{
|
||||
UINT32 cpupUse, ret;
|
||||
g_cpupTestCount++;
|
||||
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_ALL_TIME);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPU_USE_MODE1);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ret = LOS_TaskDelete(g_testTaskID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
ret = LOS_TaskDelete(g_testTaskID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
TSK_INIT_PARAM_S task1 = { 0 };
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "TskTst1";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
|
||||
task1.uwResved = TASK_STATUS_UNDETACHED;
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
g_cpupTestCount = 0;
|
||||
|
||||
LOS_TaskLock();
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 0, g_cpupTestCount);
|
||||
|
||||
LOS_TaskUnlock();
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 1, g_cpupTestCount); // 1, Here, assert that g_cpupTestCount is equal to the expected value.
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItExtendCpup005(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItExtendCpup005", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
static UINT32 TaskF02(VOID)
|
||||
{
|
||||
UINT32 ret, cpupUse;
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 2, g_cpupTestCount); // 2, Here, assert that g_cpupTestCount is equal to the expected value.
|
||||
g_cpupTestCount++;
|
||||
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(g_testTaskID01, CPUP_ALL_TIME);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ret = LOS_TaskDelete(g_testTaskID02);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
ret = LOS_TaskDelete(g_testTaskID02);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static VOID TaskF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
TSK_INIT_PARAM_S task1 = { 0 };
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "TskTst2";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
|
||||
task1.uwResved = TASK_STATUS_UNDETACHED;
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
ICUNIT_ASSERT_EQUAL_VOID(g_cpupTestCount, 0, g_cpupTestCount);
|
||||
g_cpupTestCount++;
|
||||
|
||||
g_testTaskID01 = LOS_GetCurrProcessID();
|
||||
|
||||
ret = LOS_GetTaskScheduler(LOS_CurTaskIDGet());
|
||||
// 2, used to calculate the task priority.
|
||||
ret = LOS_SetTaskScheduler(LOS_CurTaskIDGet(), ret, TASK_PRIO_TEST - 2);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, 0, ret);
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID02, &task1);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL_VOID(g_cpupTestCount, 1, g_cpupTestCount);
|
||||
g_cpupTestCount++;
|
||||
|
||||
LOS_TaskDelay(30); // 30, set delay time.
|
||||
|
||||
ICUNIT_ASSERT_EQUAL_VOID(g_cpupTestCount, 3, g_cpupTestCount); // 3, Here, assert that g_cpupTestCount is equal to the expected value.
|
||||
g_cpupTestCount++;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret, cpupUse;
|
||||
TSK_INIT_PARAM_S task1 = { 0 };
|
||||
|
||||
cpupUse = LOS_HistorySysCpuUsage(CPUP_ALL_TIME);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "TskTst1";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
|
||||
task1.uwResved = TASK_STATUS_UNDETACHED;
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
g_cpupTestCount = 0;
|
||||
INT32 pid = LOS_Fork(0, "TestCpupTsk1", TaskF01, TASK_STACK_SIZE_TEST);
|
||||
if (pid < 0) {
|
||||
ICUNIT_ASSERT_EQUAL(1, LOS_OK, 1);
|
||||
}
|
||||
|
||||
ret = LOS_Wait(pid, NULL, 0, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(pid, ret, pid);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 4, g_cpupTestCount); // 4, Here, assert that g_cpupTestCount is equal to the expected value.
|
||||
|
||||
cpupUse = LOS_HistorySysCpuUsage(CPU_USE_MODE1);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
VOID ItExtendCpup006(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItExtendCpup006", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret, cpupUse;
|
||||
|
||||
cpupUse = LOS_HistorySysCpuUsage(CPU_USE_MODE0);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
cpupUse = LOS_HistorySysCpuUsage(CPU_USE_MODE1);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
// 2, used to test history func.
|
||||
cpupUse = LOS_HistorySysCpuUsage(-2);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
cpupUse = LOS_HistorySysCpuUsage(0xFFFF);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItExtendCpup007(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItExtendCpup007", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
static UINT32 TaskF01(VOID)
|
||||
{
|
||||
UINT32 cpupUse, ret;
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 0, g_cpupTestCount);
|
||||
g_cpupTestCount++;
|
||||
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_ALL_TIME);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(g_taskMaxNum, CPUP_ALL_TIME);
|
||||
ICUNIT_GOTO_NOT_EQUAL(cpupUse, LOS_OK, cpupUse, EXIT);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 1, g_cpupTestCount);
|
||||
g_cpupTestCount++;
|
||||
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret, cpupUse;
|
||||
TSK_INIT_PARAM_S task1 = { 0 };
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "TestCpupTsk1";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
|
||||
task1.uwResved = TASK_STATUS_UNDETACHED;
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
g_cpupTestCount = 0;
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 2, g_cpupTestCount); // 2, Here, assert that g_cpupTestCount is equal to the expected value.
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItExtendCpup008(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItExtendCpup008", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 loop;
|
||||
UINT32 ret, cpupUse;
|
||||
UINT32 systemProcessNumber = LOS_GetSystemProcessMaximum();
|
||||
UINT32 cpupInfoLen;
|
||||
CPUP_INFO_S *cpup = NULL;
|
||||
|
||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||
UINT32 systemIrqNumber = LOS_GetSystemHwiMaximum();
|
||||
cpupInfoLen = systemIrqNumber * sizeof(CPUP_INFO_S);
|
||||
cpup = (CPUP_INFO_S *)LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, cpupInfoLen);
|
||||
if (cpup == NULL) {
|
||||
PRINTK("%s[%d] malloc failure!\n", __FUNCTION__, __LINE__);
|
||||
return OS_ERROR;
|
||||
}
|
||||
|
||||
ret = LOS_GetAllIrqCpuUsage(CPUP_LAST_ONE_SECONDS, cpup, cpupInfoLen);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
|
||||
for (loop = 0; loop < systemIrqNumber; loop++) {
|
||||
ICUNIT_ASSERT_SINGLE_CPUP_USAGE(cpup[loop].usage, EXIT1);
|
||||
}
|
||||
|
||||
ret = LOS_GetAllIrqCpuUsage(CPUP_LAST_TEN_SECONDS, cpup, cpupInfoLen);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
|
||||
for (loop = 0; loop < systemIrqNumber; loop++) {
|
||||
ICUNIT_ASSERT_SINGLE_CPUP_USAGE(cpup[loop].usage, EXIT1);
|
||||
}
|
||||
|
||||
ret = LOS_GetAllIrqCpuUsage(CPUP_ALL_TIME, cpup, cpupInfoLen);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
|
||||
for (loop = 0; loop < systemIrqNumber; loop++) {
|
||||
ICUNIT_ASSERT_SINGLE_CPUP_USAGE(cpup[loop].usage, EXIT1);
|
||||
}
|
||||
|
||||
LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, cpup);
|
||||
cpup = NULL;
|
||||
#endif
|
||||
|
||||
cpupInfoLen = systemProcessNumber * sizeof(CPUP_INFO_S);
|
||||
cpup = (CPUP_INFO_S *)LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, cpupInfoLen);
|
||||
if (cpup == NULL) {
|
||||
PRINTK("%s[%d] malloc failure!\n", __FUNCTION__, __LINE__);
|
||||
return OS_ERROR;
|
||||
}
|
||||
|
||||
ret = LOS_GetAllProcessCpuUsage(CPUP_LAST_ONE_SECONDS, cpup, cpupInfoLen);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
|
||||
for (loop = 0; loop < systemProcessNumber; loop++) {
|
||||
ICUNIT_ASSERT_PROCESS_CPUP_USAGE(cpup[loop].usage, EXIT1);
|
||||
}
|
||||
|
||||
ret = LOS_GetAllProcessCpuUsage(CPUP_LAST_TEN_SECONDS, cpup, cpupInfoLen);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
|
||||
for (loop = 0; loop < systemProcessNumber; loop++) {
|
||||
ICUNIT_ASSERT_PROCESS_CPUP_USAGE(cpup[loop].usage, EXIT1);
|
||||
}
|
||||
|
||||
ret = LOS_GetAllProcessCpuUsage(CPUP_ALL_TIME, cpup, cpupInfoLen);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
|
||||
for (loop = 0; loop < systemProcessNumber; loop++) {
|
||||
ICUNIT_ASSERT_PROCESS_CPUP_USAGE(cpup[loop].usage, EXIT1);
|
||||
}
|
||||
|
||||
LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, cpup);
|
||||
cpup = NULL;
|
||||
|
||||
EXIT1:
|
||||
LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, cpup);
|
||||
cpup = NULL;
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItExtendCpup011(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItExtendCpup011", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
#define ICUNIT_ASSERT_CPUP_EQUAL(cpupUse, val) \
|
||||
do { \
|
||||
if ((cpupUse) > LOS_CPUP_SINGLE_CORE_PRECISION || (cpupUse) < CPU_USE_MIN) { \
|
||||
ICUNIT_ASSERT_EQUAL(cpupUse, val, cpupUse); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static INT32 TaskF01(VOID)
|
||||
{
|
||||
INT32 testCount = 1000; // 1000, set to init testcount.
|
||||
UINT32 cpupUse;
|
||||
LOS_Mdelay(5000); // 5000, set delay time.
|
||||
|
||||
const CHAR *taskAll = "-a";
|
||||
OsShellCmdDumpTask(1, &taskAll);
|
||||
|
||||
while (testCount > 0) {
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_LAST_TEN_SECONDS);
|
||||
ICUNIT_ASSERT_CPUP_EQUAL(cpupUse, OS_INVALID_VALUE);
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_LAST_ONE_SECONDS);
|
||||
ICUNIT_ASSERT_CPUP_EQUAL(cpupUse, OS_INVALID_VALUE);
|
||||
|
||||
cpupUse = LOS_HistorySysCpuUsage(CPU_USE_MODE1);
|
||||
if ((cpupUse > LOS_CPUP_PRECISION) || (cpupUse < CPU_USE_MIN)) {
|
||||
ICUNIT_ASSERT_EQUAL(cpupUse, OS_INVALID_VALUE, cpupUse);
|
||||
}
|
||||
|
||||
testCount--;
|
||||
}
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_ALL_TIME);
|
||||
ICUNIT_ASSERT_CPUP_EQUAL(cpupUse, OS_INVALID_VALUE);
|
||||
|
||||
LOS_CpupReset();
|
||||
LOS_Mdelay(5000); // 5000, set delay time.
|
||||
|
||||
testCount = 1000; // 1000, set to init testcount.
|
||||
while (testCount > 0) {
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_LAST_TEN_SECONDS);
|
||||
ICUNIT_ASSERT_CPUP_EQUAL(cpupUse, OS_INVALID_VALUE);
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_LAST_ONE_SECONDS);
|
||||
ICUNIT_ASSERT_CPUP_EQUAL(cpupUse, OS_INVALID_VALUE);
|
||||
|
||||
cpupUse = LOS_HistorySysCpuUsage(CPU_USE_MODE1);
|
||||
if ((cpupUse > LOS_CPUP_PRECISION) || (cpupUse < CPU_USE_MIN)) {
|
||||
ICUNIT_ASSERT_EQUAL(cpupUse, OS_INVALID_VALUE, cpupUse);
|
||||
}
|
||||
testCount--;
|
||||
}
|
||||
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_ALL_TIME);
|
||||
ICUNIT_ASSERT_CPUP_EQUAL(cpupUse, OS_INVALID_VALUE);
|
||||
|
||||
OsShellCmdDumpTask(1, &taskAll);
|
||||
|
||||
EXIT:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 pid = LOS_Fork(0, "TestCpupProcess", TaskF01, TASK_STACK_SIZE_TEST);
|
||||
if (pid < 0) {
|
||||
ICUNIT_ASSERT_EQUAL(1, LOS_OK, 1);
|
||||
}
|
||||
|
||||
LOS_Wait(pid, 0, 0, 0);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItExtendCpup012(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItExtendCpup012", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
static UINT32 TaskF02(VOID)
|
||||
{
|
||||
UINT32 ret, cpupUse;
|
||||
g_cpupTestCount++;
|
||||
// 2, Here, assert that g_cpupTestCount is equal to the expected value.
|
||||
ICUNIT_GOTO_EQUAL(g_cpupTestCount, 2, g_cpupTestCount, EXIT);
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(g_testTaskID01, CPUP_ALL_TIME);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
g_cpupTestCount++;
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static UINT32 TaskF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
INT32 pid;
|
||||
g_cpupTestCount++;
|
||||
g_testTaskID01 = LOS_GetCurrProcessID();
|
||||
|
||||
pid = LOS_Fork(0, "TestCpupTsk2", TaskF02, LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE);
|
||||
if (pid < 0) {
|
||||
ICUNIT_ASSERT_EQUAL(1, LOS_OK, 1);
|
||||
}
|
||||
|
||||
LOS_TaskDelay(10); // 10, set delay time.
|
||||
g_cpupTestCount++;
|
||||
(VOID)LOS_Wait(pid, NULL, 0, NULL);
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 pid;
|
||||
UINT32 ret, cpupUse;
|
||||
g_cpupTestCount = 0;
|
||||
|
||||
cpupUse = LOS_HistorySysCpuUsage(CPUP_ALL_TIME);
|
||||
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
pid = LOS_Fork(0, "TestCpupTsk", TaskF01, LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE);
|
||||
if (pid < 0) {
|
||||
ICUNIT_ASSERT_EQUAL(1, LOS_OK, 1);
|
||||
}
|
||||
|
||||
LOS_TaskDelay(10); // 10, set delay time.
|
||||
(VOID)LOS_Wait(pid, NULL, 0, NULL);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
VOID ItExtendCpup001(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItExtendCpup001", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
static UINT32 TaskF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT32 cpupUse;
|
||||
g_cpupTestCount++;
|
||||
ICUNIT_GOTO_EQUAL(g_cpupTestCount, 1, g_cpupTestCount, EXIT);
|
||||
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPU_USE_MODE0);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPU_USE_MODE1);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPU_USE_MODE1);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 pid;
|
||||
UINT32 ret, cpupUse;
|
||||
g_cpupTestCount = 0;
|
||||
|
||||
pid = LOS_Fork(0, "TestCpupTsk", TaskF01, LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE);
|
||||
if (pid < 0) {
|
||||
ICUNIT_ASSERT_EQUAL(1, LOS_OK, 1);
|
||||
}
|
||||
|
||||
cpupUse = LOS_HistorySysCpuUsage(CPU_USE_MODE0);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
cpupUse = LOS_HistorySysCpuUsage(CPU_USE_MODE1);
|
||||
if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
|
||||
ret = LOS_NOK;
|
||||
} else {
|
||||
ret = LOS_OK;
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_Wait(pid, NULL, 0, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, pid, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItExtendCpup002(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("ItExtendCpup002", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02;
|
||||
static volatile UINT32 g_testSmpCpupStop = 0;
|
||||
static void Task01(void)
|
||||
{
|
||||
while (g_testSmpCpupStop < 1) {
|
||||
__asm__ volatile("nop");
|
||||
}
|
||||
return;
|
||||
}
|
||||
static void Task02(void)
|
||||
{
|
||||
UINT32 tempCpup;
|
||||
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
|
||||
tempCpup = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_LAST_ONE_SECONDS);
|
||||
ICUNIT_GOTO_WITHIN_EQUAL(tempCpup, LOS_CPUP_SINGLE_CORE_PRECISION - CPUP_TEST_TOLERANT,
|
||||
LOS_CPUP_SINGLE_CORE_PRECISION, tempCpup, EXIT2);
|
||||
|
||||
EXIT2:
|
||||
g_testSmpCpupStop = 1;
|
||||
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
|
||||
tempCpup = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_LAST_ONE_SECONDS);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(tempCpup, CPU_USE_MIN, tempCpup);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
TSK_INIT_PARAM_S taskInitParam;
|
||||
UINT32 ret;
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup001_task01";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
/* make sure that created test task is definitely on another core */
|
||||
UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup001_task02";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
|
||||
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * (CPUP_BACKWARD * 2 + 1)); // 2, used to calculate the delay time.
|
||||
|
||||
EIXT1:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID02);
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID01);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItSmpExtendCpup001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItSmpExtendCpup001", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
static UINT32 g_testSmpCpupTaskID01;
|
||||
|
||||
static void Task01(void)
|
||||
{
|
||||
UINT32 tempCpup;
|
||||
/* make sure that created test task is definitely on another core */
|
||||
UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
|
||||
UINT32 idleID = g_percpu[currCpuid].idleTaskID;
|
||||
TSK_INFO_S tempTaskInfo;
|
||||
|
||||
do {
|
||||
LOS_TaskInfoGet(idleID, &tempTaskInfo);
|
||||
} while (!(tempTaskInfo.usTaskStatus & OS_TASK_STATUS_RUNNING));
|
||||
|
||||
tempCpup = LOS_HistoryTaskCpuUsage(idleID, CPUP_ALL_TIME);
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL_VOID(tempCpup, CPU_USE_MIN, LOS_CPUP_SINGLE_CORE_PRECISION, tempCpup);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
TSK_INIT_PARAM_S taskInitParam;
|
||||
UINT32 ret;
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup002_task01";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND);
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID01);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItSmpExtendCpup002(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItSmpExtendCpup002", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||
static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02;
|
||||
static volatile UINT32 g_testSmpCpupStop = 0;
|
||||
static void HwiF01(void)
|
||||
{
|
||||
UINT32 i;
|
||||
UINT32 count = GetNopCount();
|
||||
for (i = 0; i < count; i++) {
|
||||
__asm__ volatile("nop");
|
||||
}
|
||||
}
|
||||
static void Task01(void)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
|
||||
|
||||
while (g_testSmpCpupStop < 1) {
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
}
|
||||
|
||||
HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(0));
|
||||
TEST_HwiDelete(HWI_NUM_TEST);
|
||||
|
||||
return;
|
||||
}
|
||||
static void Task02(void)
|
||||
{
|
||||
UINT32 tempCpup;
|
||||
|
||||
tempCpup = TestGetSingleHwiCpup(HWI_NUM_TEST, CPUP_LAST_ONE_SECONDS);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(tempCpup, CPU_USE_MIN, tempCpup);
|
||||
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
|
||||
tempCpup = TestGetSingleHwiCpup(HWI_NUM_TEST, CPUP_LAST_ONE_SECONDS);
|
||||
// 2, used to calculate the input of equal func.
|
||||
ICUNIT_GOTO_WITHIN_EQUAL(tempCpup, LOS_CPUP_SINGLE_CORE_PRECISION / 2, LOS_CPUP_SINGLE_CORE_PRECISION, tempCpup,
|
||||
EXIT2);
|
||||
|
||||
EXIT2:
|
||||
g_testSmpCpupStop = 1;
|
||||
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
|
||||
tempCpup = TestGetSingleHwiCpup(HWI_NUM_TEST, CPUP_LAST_ONE_SECONDS);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(tempCpup, CPU_USE_MIN, tempCpup);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
TSK_INIT_PARAM_S taskInitParam;
|
||||
UINT32 ret;
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup003_task01";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
/* make sure that created test task is definitely on another core */
|
||||
UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup003_task02";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
|
||||
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * (CPUP_BACKWARD * 2 + 1)); // 2, used to calculate the delay time.
|
||||
|
||||
EIXT1:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID02);
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID01);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
VOID ItSmpExtendCpup003(VOID)
|
||||
{
|
||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||
TEST_ADD_CASE("ItSmpExtendCpup003", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
#endif
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||
static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02;
|
||||
static volatile UINT32 g_testSmpCpupStop = 0;
|
||||
static HwiIrqParam g_dev1, g_dev2;
|
||||
static void HwiF01(void)
|
||||
{
|
||||
UINT32 i;
|
||||
// 2, used to calculate the conut num.
|
||||
UINT32 count = GetNopCount() / 2;
|
||||
for (i = 0; i < count; i++) {
|
||||
__asm__ volatile("nop");
|
||||
}
|
||||
}
|
||||
static void HwiF02(void)
|
||||
{
|
||||
UINT32 i;
|
||||
// 2, used to calculate the conut num.
|
||||
UINT32 count = GetNopCount() / 2;
|
||||
for (i = 0; i < count; i++) {
|
||||
__asm__ volatile("nop");
|
||||
}
|
||||
}
|
||||
|
||||
static void Task01(void)
|
||||
{
|
||||
UINT32 ret;
|
||||
g_dev1.pDevId = (void *)1;
|
||||
g_dev1.swIrq = HWI_NUM_TEST;
|
||||
// 3, used to set the hwi priority.
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF01, &g_dev1);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
|
||||
g_dev2.pDevId = (void *)2; // 2, used to set the dev ID.
|
||||
g_dev2.swIrq = HWI_NUM_TEST;
|
||||
// 3, used to set the hwi priority.
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF02, &g_dev2);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
|
||||
HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
|
||||
|
||||
while (g_testSmpCpupStop < 1) {
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
}
|
||||
|
||||
HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(0));
|
||||
ret = LOS_HwiDelete(HWI_NUM_TEST, &g_dev1);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_HwiDelete(HWI_NUM_TEST, &g_dev2);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
|
||||
return;
|
||||
}
|
||||
static void Task02(void)
|
||||
{
|
||||
UINT32 tempCpup;
|
||||
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
|
||||
tempCpup = TestGetSingleHwiCpup(HWI_NUM_TEST, CPUP_LAST_ONE_SECONDS);
|
||||
// 2, used to calculate the input of equal func.
|
||||
ICUNIT_GOTO_WITHIN_EQUAL(tempCpup, LOS_CPUP_SINGLE_CORE_PRECISION / 2, LOS_CPUP_PRECISION, tempCpup, EXIT2);
|
||||
|
||||
EXIT2:
|
||||
g_testSmpCpupStop = 1;
|
||||
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
|
||||
tempCpup = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_LAST_ONE_SECONDS);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(tempCpup, CPU_USE_MIN, tempCpup);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
TSK_INIT_PARAM_S taskInitParam;
|
||||
UINT32 ret;
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup004_task01";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
/* make sure that created test task is definitely on another core */
|
||||
UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup004_task02";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
|
||||
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * (CPUP_BACKWARD * 2 + 1)); // 2, used to calculate the delay time.
|
||||
|
||||
EIXT1:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID02);
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID01);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
VOID ItSmpExtendCpup004(VOID)
|
||||
{
|
||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||
TEST_ADD_CASE("ItSmpExtendCpup004", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
#endif
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02, g_testSmpCpupTaskID03, g_testSmpCpupTaskID04;
|
||||
static volatile UINT32 g_testSmpCpupStop = 0;
|
||||
static volatile UINT32 g_testSmpCpupCount = 0;
|
||||
|
||||
static void Task03(void)
|
||||
{
|
||||
while (g_testSmpCpupStop < 1) {
|
||||
g_testSmpCpupCount++;
|
||||
LOS_TaskYield();
|
||||
}
|
||||
return;
|
||||
}
|
||||
static void Task04(void)
|
||||
{
|
||||
while (g_testSmpCpupStop < 1) {
|
||||
g_testSmpCpupCount++;
|
||||
LOS_TaskYield();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void Task01(void)
|
||||
{
|
||||
TSK_INIT_PARAM_S taskInitParam;
|
||||
UINT32 ret;
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task03;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup005_task03";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID03, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task04;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup005_task04";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID04, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
|
||||
|
||||
while (g_testSmpCpupStop < 1) {
|
||||
g_testSmpCpupCount++;
|
||||
LOS_TaskYield();
|
||||
}
|
||||
|
||||
// 2, the g_testSmpCpupStop possible values.
|
||||
while (g_testSmpCpupStop < 2) {
|
||||
// 4, used to calculate the delay time.
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND / 4);
|
||||
}
|
||||
EXIT3:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID04);
|
||||
EXIT2:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID03);
|
||||
return;
|
||||
}
|
||||
static void Task02(void)
|
||||
{
|
||||
UINT32 tempCpup, tempCpup1, tempCpup2, tempCpup3;
|
||||
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
|
||||
tempCpup1 = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_LAST_ONE_SECONDS);
|
||||
tempCpup2 = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID03, CPUP_LAST_ONE_SECONDS);
|
||||
tempCpup3 = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID04, CPUP_LAST_ONE_SECONDS);
|
||||
tempCpup = tempCpup1 + tempCpup2 + tempCpup3;
|
||||
ICUNIT_GOTO_WITHIN_EQUAL(tempCpup, LOS_CPUP_SINGLE_CORE_PRECISION - CPUP_TEST_TOLERANT,
|
||||
LOS_CPUP_SINGLE_CORE_PRECISION, tempCpup, EXIT3);
|
||||
|
||||
EXIT3:
|
||||
g_testSmpCpupStop = 1;
|
||||
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
|
||||
tempCpup1 = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_LAST_ONE_SECONDS);
|
||||
tempCpup2 = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID03, CPUP_LAST_ONE_SECONDS);
|
||||
tempCpup3 = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID04, CPUP_LAST_ONE_SECONDS);
|
||||
tempCpup = tempCpup1 + tempCpup2 + tempCpup3;
|
||||
ICUNIT_GOTO_WITHIN_EQUAL(tempCpup, CPU_USE_MIN, CPU_USE_MIN + CPUP_TEST_TOLERANT, tempCpup, EXIT2);
|
||||
|
||||
EXIT2:
|
||||
// 2, set the g_testSmpCpupStop possible values.
|
||||
g_testSmpCpupStop = 2;
|
||||
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
TSK_INIT_PARAM_S taskInitParam;
|
||||
UINT32 ret;
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup005_task01";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
/* make sure that created test task is definitely on another core */
|
||||
UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup005_task02";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
|
||||
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * (CPUP_BACKWARD * 3 + 1)); // 3, used to calculate the delay time.
|
||||
|
||||
EIXT1:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID02);
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID01);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItSmpExtendCpup005(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItSmpExtendCpup005", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02;
|
||||
static void Task01(void)
|
||||
{
|
||||
// 2, set delay time.
|
||||
LOS_TaskDelay(2);
|
||||
|
||||
return;
|
||||
}
|
||||
static void Task02(void)
|
||||
{
|
||||
UINT32 tempCpup[2];
|
||||
UINT32 index = 0x00000001;
|
||||
|
||||
do {
|
||||
index ^= 0x00000001;
|
||||
tempCpup[index] = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_ALL_TIME);
|
||||
} while (!(LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x00) & tempCpup[index]));
|
||||
ICUNIT_ASSERT_EQUAL_VOID(tempCpup[index], LOS_ERRNO_CPUP_NO_CREATED, tempCpup[index]);
|
||||
|
||||
index ^= 0x00000001;
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL_VOID(tempCpup[index], CPU_USE_MIN, LOS_CPUP_SINGLE_CORE_PRECISION, tempCpup[index]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
TSK_INIT_PARAM_S taskInitParam;
|
||||
UINT32 ret;
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup007_task01";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
|
||||
taskInitParam.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
/* make sure that created test task is definitely on another core */
|
||||
UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup007_task02";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1;
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
|
||||
|
||||
// 10, set delay time.
|
||||
LOS_TaskDelay(10);
|
||||
|
||||
EIXT1:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID02);
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID01);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItSmpExtendCpup007(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItSmpExtendCpup007", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02;
|
||||
static void Task01(void)
|
||||
{
|
||||
// 2, set delay time.
|
||||
LOS_TaskDelay(2);
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID01);
|
||||
return;
|
||||
}
|
||||
static void Task02(void)
|
||||
{
|
||||
UINT32 tempCpup[2];
|
||||
UINT32 index = 0x00000001;
|
||||
|
||||
do {
|
||||
index ^= 0x00000001;
|
||||
tempCpup[index] = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_ALL_TIME);
|
||||
} while (!(LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x00) & tempCpup[index]));
|
||||
ICUNIT_ASSERT_EQUAL_VOID(tempCpup[index], LOS_ERRNO_CPUP_NO_CREATED, tempCpup[index]);
|
||||
|
||||
index ^= 0x00000001;
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL_VOID(tempCpup[index], CPU_USE_MIN, LOS_CPUP_SINGLE_CORE_PRECISION, tempCpup[index]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
TSK_INIT_PARAM_S taskInitParam;
|
||||
UINT32 ret;
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup008_task01";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
/* make sure that created test task is definitely on another core */
|
||||
UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup008_task02";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
|
||||
// 10, set delay time.
|
||||
LOS_TaskDelay(10);
|
||||
|
||||
EIXT1:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID02);
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID01);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItSmpExtendCpup008(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItSmpExtendCpup008", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02, g_testSmpCpupTaskID03;
|
||||
|
||||
static void Task03(void)
|
||||
{
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
|
||||
return;
|
||||
}
|
||||
|
||||
static void Task01(void)
|
||||
{
|
||||
TSK_INIT_PARAM_S taskInitParam;
|
||||
UINT32 ret;
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task03;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup009_task03";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
|
||||
taskInitParam.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID03, &taskInitParam);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
// 2, set delay time.
|
||||
LOS_TaskDelay(2);
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID03);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void Task02(void)
|
||||
{
|
||||
UINT32 tempCpup[2] = {0};
|
||||
UINT32 index = 0x00000001;
|
||||
|
||||
do {
|
||||
index ^= 0x00000001;
|
||||
tempCpup[index] = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID03, CPUP_ALL_TIME);
|
||||
} while (!(LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x00) & tempCpup[index]));
|
||||
ICUNIT_ASSERT_EQUAL_VOID(tempCpup[index], LOS_ERRNO_CPUP_NO_CREATED, tempCpup[index]);
|
||||
|
||||
index ^= 0x00000001;
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL_VOID(tempCpup[index], CPU_USE_MIN, LOS_CPUP_SINGLE_CORE_PRECISION, tempCpup[index]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
TSK_INIT_PARAM_S taskInitParam;
|
||||
UINT32 ret;
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup009_task01";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
|
||||
taskInitParam.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
/* make sure that created test task is definitely on another core */
|
||||
UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup009_task02";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
|
||||
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * (CPUP_BACKWARD + 1));
|
||||
|
||||
EIXT1:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID02);
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID01);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItSmpExtendCpup009(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItSmpExtendCpup009", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02;
|
||||
static volatile UINT32 g_testSmpCpupStop = 0;
|
||||
|
||||
static void Task01(void)
|
||||
{
|
||||
UINT32 i;
|
||||
|
||||
// 2, set delay time.
|
||||
LOS_TaskDelay(2);
|
||||
LOS_CpupReset();
|
||||
g_testSmpCpupStop = 1;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void Task02(void)
|
||||
{
|
||||
UINT32 tempCpup;
|
||||
|
||||
do {
|
||||
tempCpup = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_ALL_TIME);
|
||||
} while ((!(LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x00) & tempCpup)) && (g_testSmpCpupStop != 1));
|
||||
ICUNIT_ASSERT_EQUAL_VOID(tempCpup, LOS_ERRNO_CPUP_NO_INIT, tempCpup);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
TSK_INIT_PARAM_S taskInitParam;
|
||||
UINT32 ret;
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup001_task01";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
|
||||
taskInitParam.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
/* make sure that created test task is definitely on another core */
|
||||
UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup001_task02";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
|
||||
|
||||
// 10, set delay time.
|
||||
LOS_TaskDelay(10);
|
||||
|
||||
EIXT1:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID02);
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID01);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItSmpExtendCpup010(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItSmpExtendCpup010", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02;
|
||||
static volatile UINT32 g_testSmpCpupStop = 0;
|
||||
static CPUP_INFO_S g_psttaskcpup1st[LOSCFG_BASE_CORE_TSK_LIMIT];
|
||||
static UINT32 StatisticsTaskCpup(CPUP_INFO_S *taskCpup)
|
||||
{
|
||||
UINT32 i;
|
||||
UINT32 tmpCpup = 0;
|
||||
for (i = 0; i < LOSCFG_BASE_CORE_TSK_LIMIT; i++) {
|
||||
tmpCpup += taskCpup[i].usage;
|
||||
}
|
||||
return tmpCpup;
|
||||
}
|
||||
|
||||
static void Task01(void)
|
||||
{
|
||||
while (g_testSmpCpupStop < 1) {
|
||||
__asm__ volatile("nop");
|
||||
}
|
||||
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID01);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void Task02(void)
|
||||
{
|
||||
UINT32 tempCpup;
|
||||
UINT32 ret;
|
||||
UINT32 cpupBeforeDel;
|
||||
TSK_INFO_S tempTaskInfo;
|
||||
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
|
||||
cpupBeforeDel = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_LAST_ONE_SECONDS);
|
||||
// 2, used to calculate the input of equal func.
|
||||
ICUNIT_GOTO_WITHIN_EQUAL(cpupBeforeDel, LOS_CPUP_SINGLE_CORE_PRECISION / 2, LOS_CPUP_SINGLE_CORE_PRECISION,
|
||||
cpupBeforeDel, EXIT2);
|
||||
|
||||
EXIT2:
|
||||
g_testSmpCpupStop = 1;
|
||||
|
||||
do {
|
||||
ret = LOS_TaskInfoGet(g_testSmpCpupTaskID01, &tempTaskInfo);
|
||||
} while (ret != LOS_ERRNO_TSK_NOT_CREATED);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
TSK_INIT_PARAM_S taskInitParam;
|
||||
UINT32 ret;
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup001_task01";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
/* make sure that created test task is definitely on another core */
|
||||
UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup001_task02";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
|
||||
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * (CPUP_BACKWARD * 2 + 1)); // 2, used to calculate the delay time.
|
||||
|
||||
EIXT1:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID02);
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID01);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItSmpExtendCpup011(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItSmpExtendCpup011", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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 "It_extend_cpup.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02;
|
||||
static void Task01(void)
|
||||
{
|
||||
UINT32 tempCpup;
|
||||
UINT32 ret;
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
|
||||
ret = LOS_EventRead(&g_eventCB, 0x00000001, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
|
||||
|
||||
tempCpup = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID02, CPUP_LAST_ONE_SECONDS);
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL_VOID(tempCpup, CPU_USE_MIN, CPU_USE_MIN + CPUP_TEST_TOLERANT, tempCpup);
|
||||
|
||||
return;
|
||||
}
|
||||
static void Task02(void)
|
||||
{
|
||||
UINT32 tempCpup;
|
||||
UINT32 ret;
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
|
||||
|
||||
ret = LOS_EventRead(&g_eventCB, 0x00000001, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
|
||||
|
||||
tempCpup = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_LAST_ONE_SECONDS);
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL_VOID(tempCpup, CPU_USE_MIN, CPU_USE_MIN + CPUP_TEST_TOLERANT, tempCpup);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
TSK_INIT_PARAM_S taskInitParam;
|
||||
UINT32 ret;
|
||||
|
||||
g_eventCB.uwEventID = 0;
|
||||
ret = LOS_EventInit(&g_eventCB);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT0);
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup001_task01";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
/* make sure that created test task is definitely on another core */
|
||||
UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
|
||||
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
taskInitParam.pcName = "SmpCpup001_task02";
|
||||
taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
|
||||
|
||||
ret = LOS_EventWrite(&g_eventCB, 0x00000001);
|
||||
|
||||
LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * (CPUP_BACKWARD + 1));
|
||||
|
||||
LOS_EventClear(&g_eventCB, ~0x00000001);
|
||||
|
||||
EIXT1:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID02);
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testSmpCpupTaskID01);
|
||||
EXIT0:
|
||||
LOS_EventDestroy(&g_eventCB);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItSmpExtendCpup012(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItSmpExtendCpup012", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
Reference in New Issue
Block a user