add l0 testsuits

Change-Id: I523269c97053f484d5cb0d94397269e41eaae86c
This commit is contained in:
x_xiny
2021-04-07 11:19:43 +08:00
parent 4fc4b8c9c1
commit 449f27d5cb
605 changed files with 65396 additions and 0 deletions

378
testsuits/include/iCunit.h Normal file
View File

@@ -0,0 +1,378 @@
/*
* 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 _LOS_ICUNIT_H
#define _LOS_ICUNIT_H
#include "osTest.h"
#ifdef TST_DRVPRINT
#include "VOS_typdef.h"
#include "uartdriver.h"
#endif
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cpluscplus */
#endif /* __cpluscplus */
typedef unsigned short iUINT16;
typedef unsigned int iUINT32;
typedef signed short iINT16;
typedef signed long iINT32;
typedef char iCHAR;
typedef void iVOID;
typedef unsigned long iiUINT32;
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#define FUNCTION_TEST (1 << 0)
#define PRESSURE_TEST (1 << 1)
#define PERFORMANCE_TEST (1 << 2)
#define TEST_MODE (FUNCTION_TEST)
typedef iUINT32 (*CASE_FUNCTION)(void);
typedef struct {
iCHAR *pcCaseID;
CASE_FUNCTION pstCaseFunc;
iUINT16 testcase_layer;
iUINT16 testcase_module;
iUINT16 testcase_level;
iUINT16 testcase_type;
iiUINT32 retCode;
iUINT16 errLine;
} ICUNIT_CASE_S;
typedef struct {
iUINT16 uwCaseCnt;
iCHAR *pcSuitID;
iCHAR *pucFilename;
ICUNIT_CASE_S *pstCaseList;
iUINT16 passCnt;
iUINT16 failCnt;
} ICUNIT_SUIT_S;
typedef enum {
TEST_TASK = 0,
TEST_MEM,
TEST_SEM,
TEST_MUX,
TEST_EVENT,
TEST_QUE,
TEST_SWTMR,
TEST_HWI,
TEST_ATO,
TEST_CPUP,
TEST_SCATTER,
TEST_RUNSTOP,
TEST_TIMER,
TEST_MMU,
TEST_TICKLESS,
TEST_ROBIN,
TEST_LIBC,
TEST_WAIT,
TEST_VFAT,
TEST_YAFFS,
TEST_JFFS,
TEST_RAMFS,
TEST_NFS,
TEST_PROC,
TEST_FS,
TEST_PTHREAD,
TEST_COMP,
TEST_HWI_HALFBOTTOM,
TEST_WORKQ,
TEST_WAKELOCK,
TEST_TIMES,
TEST_LIBM,
TEST_SUPPORT,
TEST_STL,
TEST_MAIL,
TEST_MSG,
TEST_CP,
TEST_SIGNAL,
TEST_SCHED,
TEST_MTDCHAR,
TEST_TIME,
TEST_WRITE,
TEST_READ,
TEST_DYNLOAD,
TEST_REGISTER,
TEST_SR,
TEST_UNAME,
TEST_MISC,
TEST_EXC,
#if defined(LOSCFG_3RDPARTY_TEST)
TEST_THTTPD,
TEST_BIDIREFC,
TEST_CJSON,
TEST_CURL,
TEST_FFMPEG,
TEST_FREETYPE,
TEST_INIPARSER,
TEST_JSONCPP,
TEST_LIBICONV,
TEST_LIBJPEG,
TEST_LIBPNG,
TEST_OPENEXIF,
TEST_OPENSSL,
TEST_OPUS,
TEST_SQLITE,
TEST_TINYXML,
#endif
TEST_DRIVERBASE,
} LiteOS_test_module;
typedef enum {
TEST_LOS = 0,
TEST_CMSIS,
TEST_POSIX,
TEST_LIB,
TEST_VFS,
TEST_EXTEND,
TEST_PARTITION,
TEST_CPP,
TEST_SHELL,
TEST_LINUX,
TEST_USB,
#if defined(LOSCFG_3RDPARTY_TEST)
TEST_3RDPARTY,
#endif
TEST_DRIVERFRAME,
TEST_CONTEXHUB
} LiteOS_test_layer;
typedef enum {
TEST_LEVEL0 = 0,
TEST_LEVEL1,
TEST_LEVEL2,
TEST_LEVEL3
} LiteOS_test_level;
typedef enum {
TEST_FUNCTION = 0,
TEST_PRESSURE,
TEST_PERFORMANCE
} LiteOS_test_type;
extern iUINT16 iCunit_errLineNo;
extern iiUINT32 iCunit_errCode;
extern void ICunitSaveErr(iiUINT32 line, iiUINT32 retCode);
#define ICUNIT_UNINIT 0x0EF00000
#define ICUNIT_OPENFILE_FAILED 0x0EF00001
#define ICUNIT_ALLOC_FAIL 0x0EF00002
#define ICUNIT_SUIT_FULL 0x0EF00002
#define ICUNIT_CASE_FULL 0x0EF00003
#define ICUNIT_SUIT_ALL 0x0EF0FFFF
#define ICUNIT_SUCCESS 0x00000000
#define ICUNIT_TRACK_EQUAL(param, value, retcode) \
do { \
if ((param) != (value)) { \
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
} \
} while (0)
#define ICUNIT_TRACK_NOT_EQUAL(param, value, retcode) \
do { \
if ((param) == (value)) { \
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
} \
} while (0)
#define ICUNIT_ASSERT_EQUAL_VOID(param, value, retcode) \
do { \
if ((param) != (value)) { \
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
return; \
} \
} while (0)
#define ICUNIT_ASSERT_NOT_EQUAL_VOID(param, value, retcode) \
do { \
if ((param) == (value)) { \
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
return; \
} \
} while (0)
#define ICUNIT_ASSERT_EQUAL(param, value, retcode) \
do { \
if ((param) != (value)) { \
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
return 1; \
} \
} while (0)
#define ICUNIT_ASSERT_NOT_EQUAL(param, value, retcode) \
do { \
if ((param) == (value)) { \
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
return 1; \
} \
} while (0)
#define ICUNIT_ASSERT_WITHIN_EQUAL(param, value1, value2, retcode) \
do { \
if ((param) < (value1) || (param) > (value2)) { \
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
return 1; \
} \
} while (0)
#define ICUNIT_ASSERT_WITHIN_EQUAL_VOID(param, value1, value2, retcode) \
do { \
if ((param) < (value1) || (param) > (value2)) { \
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
return; \
} \
} while (0)
#define ICUNIT_ASSERT_EQUAL_VOID(param, value, retcode) \
do { \
if ((param) != (value)) { \
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
return; \
} \
} while (0)
#define ICUNIT_ASSERT_SIZE_STRING_EQUAL(str1, str2, strsize, retcode) \
do { \
if (strncmp((str1), (str2), (strsize)) != 0) { \
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
return 1; \
} \
} while (0)
#define ICUNIT_ASSERT_STRING_EQUAL(str1, str2, retcode) \
do { \
if (strcmp(str1, str2) != 0) { \
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
return 1; \
} \
} while (0)
#define ICUNIT_ASSERT_STRING_EQUAL_VOID(str1, str2, retcode) \
do { \
if (strcmp((const char *)str1, (const char *)str2) != 0) { \
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
return; \
} \
} while (0)
#define ICUNIT_ASSERT_STRING_NOT_EQUAL(str1, str2, retcode) \
do { \
if (strcmp(str1, str2) == 0) { \
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
return 1; \
} \
} while (0)
#define ICUNIT_GOTO_EQUAL(param, value, retcode, label) \
do { \
if ((param) != (value)) { \
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
goto label; \
} \
} while (0)
#define ICUNIT_GOTO_NOT_EQUAL(param, value, retcode, label) \
do { \
if ((param) == (value)) { \
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
goto label; \
} \
} while (0)
#define ICUNIT_GOTO_STRING_EQUAL(str1, str2, retcode, label) \
do { \
if (strcmp(str1, str2) != 0) { \
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
goto label; \
} \
} while (0)
#define ICUNIT_GOTO_STRING_NOT_EQUAL(str1, str2, retcode, label) \
do { \
if (strcmp(str1, str2) == 0) { \
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
goto label; \
} \
} while (0)
extern iUINT32 iCunitAddSuit_F(iCHAR *suitName, iCHAR *pfileName);
#define iCunitAddSuit(suitName) iCunitAddSuit_F(suitName, __FILE__)
extern iUINT32 ICunitAddCase(iCHAR *caseName, CASE_FUNCTION caseFunc, iUINT16 testcaseLayer, iUINT16 testcaseModule,
iUINT16 testcaseLevel, iUINT16 testcaseType);
extern iUINT32 ICunitRun(void);
extern iUINT32 ICunitInit(void);
extern iUINT32 iCunitPrintReport(void);
#define TEST_ADD_CASE(name, casefunc, testcase_layer, testcase_module, testcase_level, testcase_type) \
do { \
iUINT32 uwRet = 1; \
uwRet = ICunitAddCase(name, (CASE_FUNCTION)casefunc, testcase_layer, testcase_module, testcase_level, \
testcase_type); \
ICUNIT_ASSERT_EQUAL_VOID(uwRet, ICUNIT_SUCCESS, uwRet); \
} while (0)
#define TEST_RUN_SUITE() \
do { \
UINT32 uiRet; \
uiRet = ICunitRun(); \
ICUNIT_ASSERT_NOT_EQUAL_VOID(uiRet, ICUNIT_UNINIT, ICUNIT_UNINIT); \
} while (0)
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cpluscplus */
#endif /* __cpluscplus */
#endif /* _UNI_ICUNIT_H */

View File

@@ -0,0 +1,68 @@
/*
* 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 _ICUNIT_ICUNIT_INC
#define _ICUNIT_ICUNIT_INC
#include "iCunit_config.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
ICUNIT_CASE_S iCunit_CaseArray[ICUNIT_CASE_SIZE];
ICUNIT_SUIT_S iCunit_SuitArray[ICUNIT_SUIT_SIZE];
iUINT32 iCunit_Init_Success = 0x0000FFFF;
iUINT32 iCunit_Case_Cnt = 0xFFFF;
iUINT32 iCunit_Suit_Cnt = 0xFFFF;
iUINT32 iCunit_Case_Idx = 0xFFFF;
iUINT32 iCunit_Suit_Idx = 0xFFFF;
iUINT32 iCunit_Case_FailedCnt = 0;
iUINT32 iCunit_Suit_FailedCnt = 0;
iUINT32 iCunit_ErrLog_AddSuit = 0;
iUINT32 iCunit_ErrLog_AddCase = 0;
iUINT16 iCunit_errLineNo;
iiUINT32 iCunit_errCode;
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _UNI_ICUNIT_INC */

View File

@@ -0,0 +1,52 @@
/*
* 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 _ICUNIT_CONFIG_H
#define _ICUNIT_CONFIG_H
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cpluscplus */
#endif /* __cpluscplus */
#define ICUNIT_CASE_SIZE 1500
#define ICUNIT_SUIT_SIZE 200
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cpluscplus */
#endif /* __cpluscplus */
#endif

View File

@@ -0,0 +1,272 @@
/*
* 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 _LOS_DLINK_MEM_H
#define _LOS_DLINK_MEM_H
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#if (OS_SYS_MEM_CHECK == YES)
#define LOS_DLNK_ENABLE_ALLOC_CHECK
#endif
typedef VOID (*MALLOC_HOOK)(VOID);
extern MALLOC_HOOK g_mallocHook;
/* *
* @ingroup los_dlinkmem
* Memory pool information structure
*/
typedef struct {
void *pPoolAddr; /* *<Starting address of a memory pool */
UINT32 uwPoolSize; /* *<Memory pool size */
} LOS_DLNK_POOL_INFO;
/* *
* @ingroup los_dlinkmem
* Memory linked list node structure
*/
typedef struct tagLOS_DLNK_NODE {
LOS_DL_LIST stFreeNodeInfo; /* *<Free memory node */
struct tagLOS_DLNK_NODE *pstPreNode; /* *<Pointer to the previous memory node */
UINT32 uwSizeAndFlag; /* *<Size and flag of the current node (the highest bit represents a flag, and the rest bits
specify the size) */
} LOS_DLNK_NODE;
/* *
* @ingroup los_dlinkmem
* @brief Initialize dynamic memory.
*
* @par Description:
* <ul>
* <li>This API is used to initialize the dynamic memory of a doubly linked list.</li>
* </ul>
* @attention
* <ul>
* <li>Call this API when dynamic memory needs to be initialized during the startup of HuaweiLite OS.</li>
* </ul>
*
* @param pool [IN] Starting address of memory.
* @param size [IN] Memory size.
*
* @retval #OS_ERROR <20>C1: The dynamic memory fails to be initialized.
* @retval #LOS_OK 0: The dynamic memory is successfully initialized.
* @par Dependency:
* <ul>
* <li>los_dlinkmem.h: the header file that contains the API declaration.</li>
* </ul>
* @see None.
*/
extern UINT32 LOS_DLnkInitMem(VOID *pool, UINT32 size);
/* *
* @ingroup los_dlinkmem
* @brief Allocate memory.
*
* @par Description:
* <ul>
* <li>This API is used to allocate memory of which the size is specified by size.</li>
* </ul>
* @attention
* <ul>
* <li>After calling this API, ensure that the returned memory address is not null in case that a null pointer will be
accessed later.</li>
* </ul>
*
* @param pool [IN] Starting address of memory.
* @param size [IN] Size of the memory to be allocated (unit: byte).
*
* @retval Address of the allocated memory. The memory is successfully allocated.
* @retval NULL. The memory fails to be allocated.
* @par Dependency:
* <ul>
* <li>los_dlinkmem.h: the header file that contains the API declaration.</li>
* </ul>
* @see LOS_DLnkFreeMem
*/
extern void *LOS_DLnkAllocMem(VOID *pool, UINT32 size);
/* *
* @ingroup los_dlinkmem
* @brief Free memory.
*
* @par Description:
* <ul>
* <li>This API is used to free the allocated memory.</li>
* </ul>
* @attention
* <ul>
* <li>The memory fails to be freed if it has been already freed.</li>
* </ul>
*
* @param pool [IN] Starting address of memory.
* @param mem [IN] Address of the memory to be freed.
*
* @retval #LOS_NOK 1: The memory fails to be freed.
* @retval #LOS_OK 0: The memory is successfully freed.
* @par Dependency:
* <ul>
* <li>los_dlinkmem.h: the header file that contains the API declaration.</li>
* </ul>
* @see LOS_DLnkAllocMem
*/
extern UINT32 LOS_DLnkFreeMem(VOID *pool, VOID *mem);
/* *
* @ingroup los_dlinkmem
* @brief Re-allocate memory.
*
* @par Description:
* <ul>
* <li>This API is used to re-allocate memory if the memory allocated before is insufficient. Data in the original memory
will be copied to the re-allocated memory, after which the original memory will be freed.</li>
* </ul>
* @attention
* <ul>
* <li>Before calling this API, check whether the return value of this API is null.</li>
* <li>If the passed-in address of the original memory is not null, and the passed-in size of the new memory block is 0,
calling this API frees the original memory.</li>
* <li>If the passed-in address of the original memory is null, calling this API allocates a new memory block.</li>
* <li>If the new memory block fails to be allocated, the original one will not be released.</li>
* </ul>
*
* @param pool [IN] Starting address of memory.
* @param ptr [IN] Address of the re-allocated memory.
* @param size [IN] Size of the memory to be allocated.
*
* @retval Address of the re-allocated memory. The memory is successfully re-allocated.
* @retval NULL. The memory fails to be re-allocated.
* @par Dependency:
* <ul>
* <li>los_dlinkmem.h: the header file that contains the API declaration.</li>
* </ul>
* @see LOS_DLnkAllocMem
*/
extern void *LOS_DLnkReAllocMem(VOID *pool, VOID *ptr, UINT32 size);
/* *
* @ingroup los_dlinkmem
* @brief Allocate aligned memory.
*
* @par Description:
* <ul>
* <li>This API is used to allocate memory blocks of specified size and of which the starting addresses are aligned on a
* specified boundary.</li>
* </ul>
* @attention
* <ul>
* <li>The alignment parameter value must be a power of 2 with the minimum value being 4.</li>
* </ul>
*
* @param pool [IN] Starting address of memory.
* @param size [IN] Size of the memory to be allocated.
* @param boundary[IN] Boundary on which the memory is aligned.
*
* @retval Starting address of the allocated aligned memory. The memory is successfully allocated.
* @retval The memory fails to be allocated.
* @par Dependency:
* <ul>
* <li>los_dlinkmem.h: the header file that contains the API declaration.</li>
* </ul>
* @see None.
*/
extern void *LOS_DlnkAllocMemAlign(void *pool, UINT32 size, UINT32 boundary);
extern UINT32 LOS_DLnkCheckMem(void *pool);
extern UINT32 LOS_DLnkGetTotalMemUsed(void *pool);
extern UINT32 LOS_DLnkGetMemFreeBlks(void *pool);
extern UINT32 LOS_DLnkGetMemUsedBlks(void *pool);
extern UINT32 LOS_DLnkGetMemTskId(void *ptr);
#ifdef OS_MEM_CHECK_DEBUG
/*
* memcheck error code: the stack have not inited
* Value: 0x02000100
* Solution: do memcheck must after stack mem init
*/
#define OS_ERRNO_MEMCHECK_NOT_INIT LOS_ERRNO_OS_ERROR(OS_MOD_MEM, 0x0)
/*
* memcheck error code: the pPtr is NULL
* Value: 0x02000101
* Solution: don't give a NULL parameter
*/
#define OS_ERRNO_MEMCHECK_PARA_NULL LOS_ERRNO_OS_ERROR(OS_MOD_MEM, 0x1)
/*
* memcheck error code: the pPtr addr not in the suit range
* Value: 0x02000102
* Solution: check pPtr and comfirm it included by stack
*/
#define OS_ERRNO_MEMCHECK_OUTSIDE LOS_ERRNO_OS_ERROR(OS_MOD_MEM, 0x2)
/*
* memcheck error code: can't find the ctrl node
* Value: 0x02000103
* Solution: confirm the pPtr if this node has been freed or has not been alloced
*/
#define OS_ERRNO_MEMCHECK_NO_HEAD LOS_ERRNO_OS_ERROR(OS_MOD_MEM, 0x3)
/*
* memcheck error code: the para level is wrong
* Value: 0x02000104
* Solution: checkout the memcheck level by the func mCheck_Level"
*/
#define OS_ERRNO_MEMCHECK_WRONG_LEVEL LOS_ERRNO_OS_ERROR(OS_MOD_MEM, 0x4)
/*
* memcheck error code: memcheck func not open
* Value: 0x02000105
* Solution: enable memcheck by the func "OS_SetMemCheck_Level"
*/
#define OS_ERRNO_MEMCHECK_DISABLED LOS_ERRNO_OS_ERROR(OS_MOD_MEM, 0x5)
#define LOS_MEM_CHECK_LEVEL_LO 0
#define LOS_MEM_CHECK_LEVEL_HI 1
#define LOS_MEM_CHECK_DISABLE 0xff
#define LOS_MEM_CHECK_LEVEL_D OS_ERRNO_MEMCHECK_DISABLED
extern UINT32 LOS_CheckMemSize(VOID *pool, VOID *ptr, UINT32 *totalSize, UINT32 *availSize);
extern UINT32 LOS_SetMemCheck_Level(UINT8 level);
extern UINT8 LOS_GetMemCheck_Level(VOID);
#endif
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_DLINK_MEM_H */

376
testsuits/include/osTest.h Normal file
View File

@@ -0,0 +1,376 @@
/*
* 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 _OSTEST_H
#define _OSTEST_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "iCunit.h"
#include "los_debug.h"
#include "los_config.h"
#include "los_interrupt.h"
#include "los_arch_interrupt.h"
#include "los_task.h"
#include "los_sem.h"
#include "los_event.h"
#include "los_memory.h"
#include "los_queue.h"
#include "los_cpup.h"
#include "los_tick.h"
#include "los_swtmr.h"
#include "los_mux.h"
#include "securec.h"
#include "securectype.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cpluscplus */
#endif /* __cpluscplus */
#define PRINTF(fmt, args...) \
do { \
printf(fmt, ##args); \
} while (0)
#define LITEOS_BASE_TEST 1
#define LOS_KERNEL_CORE_TASK_TEST 1
#define LOS_KERNEL_IPC_MUX_TEST 1
#define LOS_KERNEL_IPC_SEM_TEST 1
#define LOS_KERNEL_IPC_EVENT_TEST 1
#define LOS_KERNEL_IPC_QUEUE_TEST 1
#define LOS_KERNEL_CORE_SWTMR_TEST 1
#define LOS_KERNEL_HWI_TEST 1
#define LOS_KERNEL_FS_TEST 0
#define LOS_KERNEL_MEM_TEST 1
#define LOS_KERNEL_TICKLESS_TEST 0
#define LITEOS_CMSIS_TEST 0
#define LOS_CMSIS2_CORE_TASK_TEST 0
#define LOS_CMSIS2_IPC_MUX_TEST 0
#define LOS_CMSIS2_IPC_SEM_TEST 0
#define LOS_CMSIS2_IPC_EVENT_TEST 0
#define LOS_CMSIS2_IPC_MSG_TEST 0
#define LOS_CMSIS2_CORE_SWTMR_TEST 0
#define LOS_CMSIS2_HWI_TEST 0
#define LOSCFG_TEST_LLT 0
#define LOSCFG_TEST_MUCH_LOG 0
extern UINT32 volatile g_testCount;
extern UINT32 g_testTskHandle;
extern UINT32 g_testTaskID01;
extern UINT32 g_testTaskID02;
extern UINT32 g_testTaskID03;
extern UINT32 g_testTaskID04;
extern UINT32 g_hwiNum1;
extern UINT32 g_hwiNum2;
extern UINT32 g_usSemID;
extern UINT32 g_usSemID2;
extern UINT32 g_mutexTest;
extern UINT16 g_usSwTmrID;
extern UINT32 g_usSemID;
extern UINT32 g_testQueueID01;
extern UINT32 g_testQueueID02;
extern UINT32 g_testQueueID03;
extern UINT32 g_testTskHandle;
extern UINT32 g_leavingTaskNum;
extern UINT32 g_testTaskIdArray[LOSCFG_BASE_CORE_TSK_LIMIT];
extern UINT16 g_index;
extern UINT32 g_usSemID3[];
extern EVENT_CB_S g_exampleEvent;
#ifndef LOS_TASK_MIN_TEST_STACK_SIZE
#define LOS_TASK_MIN_TEST_STACK_SIZE LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE + 0x20
#endif
#ifndef TASK_TEST
#define TASK_TEST
#endif
#ifndef SWTMR_TEST
#define SWTMR_TEST
#endif
#ifndef QUEUE_TEST
#define QUEUE_TEST
#endif
#ifndef SEM_TEST
#define SEM_TEST
#endif
#ifndef EVENT_TEST
#define EVENT_TEST
#endif
#ifndef HWI_TEST
#define HWI_TEST
#endif
#ifndef TICK_TEST
#define TICK_TEST
#endif
#ifndef EXC_TEST
#define EXC_TEST
#endif
#ifndef MEMCHECK_TEST
#define MEMCHECK_TEST
#endif
#ifndef MACRO_BASE_FUNCTION_TEST
#define MACRO_BASE_FUNCTION_TEST
#endif
#ifndef MACRO_EXC_TEST
#define MACRO_EXC_TEST
#endif
#ifndef MACRO_PRESSURE_TEST
#define MACRO_PRESSURE_TEST
#endif
#ifdef MACRO_PREESSURE_TEST
#define DIVISOR 1
#else
#define DIVISOR 10
#endif
#ifndef TEST_CASE_RES_CHECK
#define TEST_CASE_RES_CHECK
#endif
#ifndef TST_IT
#define TST_IT
#endif
#define TEST_PT YES
#if (YES == OS_INCLUDE_DYNMEM)
#define TEST_BIG YES
#else
#define TEST_BIG NO
#endif
#define TASK_PRIO_TEST 25
#define TASK_PRIO_TEST_NORMAL 20
#define TASK_STACK_SIZE_TEST 0x400
#define TASK_LOOP_NUM 0x100000
#define QUEUE_LOOP_NUM 100
#define HWI_LOOP_NUM 100
#define SWTMR_LOOP_NUM 1000
#define TASK_NAME_NUM 10
#define TEST_TASK_RUNTIME 0x100000
#define TEST_SWTMR_RUNTIME 0x1000000
#define TEST_HWI_RUNTIME 0x100000
#define TEST_TASK_STACK_SIZE LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE
#define TEST_TASK_PRIORITY_LOW osPriorityBelowNormal // tskIDLE_PRIORITY + 10
#define TEST_TASK_PRIORITY_NORMAL osPriorityNormal // tskIDLE_PRIORITY + 11
#define TEST_TASK_PRIORITY_HIGH osPriorityAboveNormal // tskIDLE_PRIORITY + 12
#define TEST_TASK_PRIORITY_MAX osPriorityAboveNormal5
#define LOS_TASK_STATUS_DETACHED 0x0100
#define LOS_SYS_MS_PER_SECOND 1000 // Number of ms in one second.
#define LOS_SYS_US_PER_SECOND 1000000 // Number of us in one second.
#define LOS_MS_PER_TICK (LOS_SYS_MS_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND)
#ifdef LOS_HIMIDEER_RV32
#define OS_TSK_TEST_STACK_SIZE 0x9000
#else
#define OS_TSK_TEST_STACK_SIZE 0x1000
#endif
#define TASK_CMSIS_STACK_SIZE_TEST 0x600
#define OS_EVENT_TIMEOUT_MAX_VAL 0xFFFFFFFF
#if (LOSCFG_BASE_CORE_SWTMR == 1)
#define TASK_EXISTED_NUM 3
#else
#define TASK_EXISTED_NUM 2
#endif
#if (LOSCFG_BASE_CORE_SWTMR == 1)
#define QUEUE_EXISTED_NUM 1
#else
#define QUEUE_EXISTED_NUM 0
#endif
#define HWI_NUM_INT_NEG (-4)
#define HWI_NUM_INT0 0
#define HWI_NUM_INT1 1
#define HWI_NUM_INT2 2
#define HWI_NUM_INT3 3
#define HWI_NUM_INT4 4
#define HWI_NUM_INT5 5
#define HWI_NUM_INT6 6
#define HWI_NUM_INT7 7
#define HWI_NUM_INT11 11
#define HWI_NUM_INT12 12
#define HWI_NUM_INT13 13
#define HWI_NUM_INT14 14
#define HWI_NUM_INT15 15
#define HWI_NUM_INT16 16
#define HWI_NUM_INT17 17
#define HWI_NUM_INT18 18
#define HWI_NUM_INT21 21
#define HWI_NUM_INT22 22
#define HWI_NUM_INT23 23
#define HWI_NUM_INT24 24
#define HWI_NUM_INT25 25
#define HWI_NUM_INT26 26
#define HWI_NUM_INT27 27
#define HWI_NUM_INT28 28
#define HWI_NUM_INT30 30
#define HWI_NUM_INT31 31
#define HWI_NUM_INT32 32
#define HWI_NUM_INT33 33
#define HWI_NUM_INT45 45
#define HWI_NUM_INT50 50
#define HWI_NUM_INT55 55
#define HWI_NUM_INT60 60
#define HWI_NUM_INT58 58
#define HWI_NUM_INT59 59
#define HWI_NUM_INT75 75
#define HWI_NUM_INT71 71
#define HWI_NUM_INT72 72
#define HWI_NUM_INT73 73
#ifdef LOS_HIMIDEER_RV32
#define HWI_NUM_TEST 32
#define HWI_NUM_TEST0 33
#define HWI_NUM_TEST1 34
#define HWI_NUM_TEST2 35
#define HWI_NUM_TEST3 36
#else
#define HWI_NUM_TEST0 HWI_NUM_INT1
#define HWI_NUM_TEST HWI_NUM_INT7
#define HWI_NUM_TEST1 HWI_NUM_INT11
#define HWI_NUM_TEST2 HWI_NUM_INT12
#define HWI_NUM_TEST3 HWI_NUM_INT14
#endif
#define LOSCFG_BASE_IPC_QUEUE_CONFIG LOSCFG_BASE_IPC_QUEUE_LIMIT
#define LOSCFG_BASE_IPC_SEM_CONFIG LOSCFG_BASE_IPC_SEM_LIMIT
#define LOSCFG_BASE_CORE_SWTMR_CONFIG LOSCFG_BASE_CORE_SWTMR_LIMIT
#define LOSCFG_BASE_CORE_TSK_CONFIG LOSCFG_BASE_CORE_TSK_LIMIT
#define dprintf printf
#define IT_SEM_COUNT_MAX OS_SEM_COUNTING_MAX_COUNT
extern EVENT_CB_S g_pstEventCb01;
extern EVENT_CB_S g_pstEventCb02;
extern EVENT_CB_S g_pstEventCb03;
extern UINT32 TEST_TskDelete(UINT32 taskID);
extern UINT32 TestSemDelete(UINT32 semHandle);
extern UINT32 TestHwiDelete(UINT32 hwiNum);
extern VOID TEST_HwiDeleteAll(VOID);
extern VOID TestHwiTrigger(UINT32 hwiNum);
extern VOID TestHwiClear(UINT32 hwiNum);
#ifdef LOS_HIMIDEER_RV32
extern UINT64 LosCpuCycleGet(VOID);
#else
typedef struct tagHwiHandleForm {
HWI_PROC_FUNC pfnHook;
UINT32 uwPrioMask;
} HWI_HANDLE_FORM_S;
#endif
#define TEST_HwiCreate(ID, prio, mode, Func, arg) HalHwiCreate(ID, prio, mode, Func, arg)
#define LOS_HwiCreate(ID, prio, mode, Func, arg) HalHwiCreate(ID, prio, mode, Func, arg)
#define uart_printf_func printf
extern VOID ItSuiteLosTask(void);
extern VOID ItSuiteLosQueue(void);
extern VOID ItSuiteLosMux(void);
extern VOID ItSuiteLosEvent(void);
extern VOID ItSuiteLosSem(void);
extern VOID ItSuiteLosSwtmr(void);
extern VOID ItSuiteLosHwi(void);
extern VOID ItSuiteLosMem(void);
extern VOID ItSuite_Los_FatFs(void);
extern VOID ItSuite_Cmsis_Lostask(void);
extern VOID ItSuite_Cmsis_Lostask_add(void);
extern VOID ItSuite_CMSIS_Losmsg(void);
extern VOID ItSuite_CMSIS_Losmsg_add(void);
extern VOID ItSuite_CMSIS_Signal(void);
extern VOID ItSuite_CMSIS_Signal_add(void);
extern VOID ItSuite_Cmsis_LosMemBox(void);
extern VOID ItSuite_Cmsis_LosMutex(void);
extern VOID ItSuite_Cmsis_LosMutex_add(void);
extern VOID ItSuite_Cmsis_LosRobin(void);
extern VOID ItSuite_Cmsis_LosRobin_add(void);
extern VOID ItSuite_CMSIS_Losmail(void);
extern VOID ItSuite_CMSIS_Losmail_add(void);
extern VOID ItSuite_Cmsis_LosSem(void);
extern VOID ItSuite_Cmsis_LosSem_add(void);
extern VOID ItSuite_CMSIS_Swtmr(void);
extern VOID ItSuite_CMSIS_Swtmr_add(void);
extern VOID ItSuite_Cmsis_Hwi_M3(VOID);
extern VOID ItSuite_Cmsis_Hwi_M3_add(void);
extern VOID ItSuite_CMSIS_Wait(void);
extern VOID ItSuite_CMSIS_Wait_add(VOID);
#define OS_MS_TO_TICK(ms) (((ms) * (UINT64)LOSCFG_BASE_CORE_TICK_PER_SECOND) / 1000)
extern UINT32 g_usSemID;
extern UINT32 g_auwTestTaskID[LOSCFG_BASE_CORE_TSK_LIMIT];
extern LosQueueCB *g_pstAllQueue;
extern UINT32 g_taskMaxNum;
extern LITE_OS_SEC_BSS_INIT LOS_DL_LIST g_stUnusedSemList;
extern VOID HalHwiDefaultHandler(VOID);
extern LosTask g_losTask;
extern VOID LOS_Schedule(VOID);
extern LosTaskCB *g_taskCBArray;
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cpluscplus */
#endif /* __cpluscplus */
#endif /* _OSTEST_H */