diff --git a/arch/arm/cortex-m55/gcc/NTZ/los_timer.c b/arch/arm/cortex-m55/gcc/NTZ/los_timer.c
index 538c1f37..b284544d 100755
--- a/arch/arm/cortex-m55/gcc/NTZ/los_timer.c
+++ b/arch/arm/cortex-m55/gcc/NTZ/los_timer.c
@@ -35,7 +35,7 @@
#include "los_debug.h"
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
-STATIC VOID SysTickReload(UINT64 nextResponseTime);
+STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
STATIC UINT64 SysTickCycleGet(UINT32 *period);
STATIC VOID SysTickLock(VOID);
STATIC VOID SysTickUnlock(VOID);
diff --git a/arch/csky/v2/gcc/los_interrupt.c b/arch/csky/v2/gcc/los_interrupt.c
index 43786da3..63525aee 100644
--- a/arch/csky/v2/gcc/los_interrupt.c
+++ b/arch/csky/v2/gcc/los_interrupt.c
@@ -256,7 +256,7 @@ VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
**************************************************************************** */
STATIC UINT32 HwiNumGet(VOID)
{
- return HalGetPsr();
+ return (HalGetPsr() >> PSR_VEC_OFFSET) & MASK_8_BITS;
}
HwiControllerOps g_archHwiOps = {
@@ -283,7 +283,6 @@ inline UINT32 ArchIsIntActive(VOID)
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
UINT32 irqNum = HwiNumGet();
- irqNum = (irqNum >> PSR_VEC_OFFSET) & MASK_8_BITS;
PRINT_ERR("%s irqnum:%x\n", __FUNCTION__, irqNum);
while (1) {}
}
@@ -315,7 +314,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
hwiIndex = HwiNumGet();
- hwiIndex = (hwiIndex >> PSR_VEC_OFFSET) & MASK_8_BITS;
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
HalPreInterruptHandler(hwiIndex);
diff --git a/arch/include/los_interrupt.h b/arch/include/los_interrupt.h
index a9208ef1..49cf57c8 100644
--- a/arch/include/los_interrupt.h
+++ b/arch/include/los_interrupt.h
@@ -80,6 +80,7 @@ UINT32 ArchIsIntActive(VOID);
#define LOS_HwiDisable ArchIntDisable
#define LOS_HwiClear ArchIntClear
#define LOS_HwiSetPriority ArchIntSetPriority
+#define LOS_HwiCurIrqNum ArchIntCurIrqNum
UINT32 ArchIntLock(VOID);
#define LOS_IntLock ArchIntLock
@@ -193,6 +194,14 @@ STATIC INLINE UINT32 ArchIntSetPriority(HWI_HANDLE_T hwiNum, HWI_PRIOR_T priorit
return g_archHwiOps.setIrqPriority(hwiNum, priority);
}
+STATIC INLINE UINT32 ArchIntCurIrqNum(VOID)
+{
+ if (g_archHwiOps.getCurIrqNum == NULL) {
+ return LOS_NOK;
+ }
+ return g_archHwiOps.getCurIrqNum();
+}
+
STATIC INLINE HwiControllerOps *ArchIntOpsGet(VOID)
{
return &g_archHwiOps;
diff --git a/kal/posix/src/pthread_mutex.c b/kal/posix/src/pthread_mutex.c
index 8adfe96a..bda54788 100644
--- a/kal/posix/src/pthread_mutex.c
+++ b/kal/posix/src/pthread_mutex.c
@@ -49,7 +49,7 @@ static inline int MapError(UINT32 err)
switch (err) {
case LOS_OK:
return 0;
- case LOS_ERRNO_MUX_PEND_INTERR:
+ case LOS_ERRNO_MUX_IN_INTERR:
return EPERM;
case LOS_ERRNO_MUX_PEND_IN_LOCK:
return EDEADLK;
@@ -134,7 +134,7 @@ int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexA
if (mutex == NULL) {
return EINVAL;
}
-
+
if (mutexAttr == NULL) {
(VOID)pthread_mutexattr_init(&useAttr);
} else {
@@ -324,7 +324,7 @@ int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *absTi
UINT64 timeoutNs;
struct timespec curTime = {0};
LosMuxCB *muxPended = NULL;
-
+
ret = MuxPreCheck(mutex, OS_TCB_FROM_TID(LOS_CurTaskIDGet()));
if (ret != 0) {
return (INT32)ret;
diff --git a/kernel/include/los_mux.h b/kernel/include/los_mux.h
index 822472d6..1af906f4 100644
--- a/kernel/include/los_mux.h
+++ b/kernel/include/los_mux.h
@@ -104,7 +104,7 @@ extern "C" {
*
* Solution: Check whether the mutex is being locked during an interrupt.
*/
-#define LOS_ERRNO_MUX_PEND_INTERR LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x05)
+#define LOS_ERRNO_MUX_IN_INTERR LOS_ERRNO_OS_ERROR(LOS_MOD_MUX, 0x05)
/**
* @ingroup los_mux
@@ -256,7 +256,7 @@ extern UINT32 LOS_MuxDelete(UINT32 muxHandle);
* is not applicable for the current operation.
* @retval #LOS_ERRNO_MUX_UNAVAILABLE The mutex fails to be locked because it is locked by another thread and
* a period of time is not set for waiting for the mutex to become available.
- * @retval #LOS_ERRNO_MUX_PEND_INTERR The mutex is being locked during an interrupt.
+ * @retval #LOS_ERRNO_MUX_IN_INTERR The mutex is being locked during an interrupt.
* @retval #LOS_ERRNO_MUX_PEND_IN_LOCK The mutex is waited on when the task scheduling is disabled.
* @retval #LOS_ERRNO_MUX_TIMEOUT The mutex waiting times out.
* @retval #LOS_OK The mutex is successfully locked.
@@ -284,7 +284,7 @@ extern UINT32 LOS_MuxPend(UINT32 muxHandle, UINT32 timeout);
*
* @retval #LOS_ERRNO_MUX_INVALID The mutex state (for example, the mutex does not exist or is not in use
* or owned by other thread) is not applicable for the current operation.
- * @retval #LOS_ERRNO_MUX_PEND_INTERR The mutex is being released during an interrupt.
+ * @retval #LOS_ERRNO_MUX_IN_INTERR The mutex is being released during an interrupt.
* @retval #LOS_OK The mutex is successfully released.
* @par Dependency:
*
- los_mux.h: the header file that contains the API declaration.
diff --git a/kernel/include/los_queue.h b/kernel/include/los_queue.h
index 9874a14c..e1d43104 100644
--- a/kernel/include/los_queue.h
+++ b/kernel/include/los_queue.h
@@ -333,7 +333,17 @@ extern "C" {
/**
* @ingroup los_queue
- * In struct QUEUE_INFO_S, the length of each waitReadTask/waitWriteTask/waitMemTask array depends on the value
+ * Queue error code: The buffer size passed in during queue readding or writting is bigger than the biggest size.
+ *
+ * Value: 0x02000620
+ *
+ * Solution: Decrease the buffer size.
+ */
+#define LOS_ERRNO_QUEUE_BUFFER_SIZE_TOO_BIG LOS_ERRNO_OS_ERROR(LOS_MOD_QUE, 0x20)
+
+/**
+ * @ingroup los_queue
+ * In struct QueueInfo, the length of each waitReadTask/waitWriteTask/waitMemTask array depends on the value
* LOSCFG_BASE_CORE_TSK_LIMIT. The type of each array element is UINT32, which means that each element could mark 32(=2^5) tasks.
* OS_WAIT_TASK_ARRAY_LEN is used to calculate the array length.
* OS_WAIT_TASK_ID_TO_ARRAY_IDX is used to transfer task ID to array index.
@@ -387,7 +397,7 @@ typedef struct tagQueueInfo {
* - los_queue.h: the header file that contains the API declaration.
* @see LOS_QueueDelete
*/
-extern UINT32 LOS_QueueCreate(CHAR *queueName,
+extern UINT32 LOS_QueueCreate(const CHAR *queueName,
UINT16 len,
UINT32 *queueID,
UINT32 flags,
diff --git a/kernel/include/los_task.h b/kernel/include/los_task.h
index 52f3312d..194636a9 100644
--- a/kernel/include/los_task.h
+++ b/kernel/include/los_task.h
@@ -1142,25 +1142,6 @@ extern UINT32 LOS_NewTaskIDGet(VOID);
*/
extern CHAR* LOS_TaskNameGet(UINT32 taskID);
-/* *
- * @ingroup los_task
- * @brief: cpu delay.
- *
- * @par Description:
- * This API is used to cpu delay, no task switching.
- *
- * @attention:
- *
- *
- * @param UINT64 [IN] delay times, microseconds.
- *
- * @retval: None.
- * @par Dependency:
- * - los_task.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID LOS_UDelay(UINT64 microseconds);
-
/* *
* @ingroup los_task
* @brief: cpu delay.
@@ -1779,6 +1760,8 @@ STATIC INLINE LosTaskCB *OsCurrTaskGet(VOID)
return g_losTask.runTask;
}
+extern VOID LOS_TaskResRecycle(VOID);
+
#ifdef __cplusplus
#if __cplusplus
}
diff --git a/kernel/include/los_tick.h b/kernel/include/los_tick.h
index 057f0d80..7920c511 100644
--- a/kernel/include/los_tick.h
+++ b/kernel/include/los_tick.h
@@ -137,6 +137,8 @@ extern UINT32 g_sysClock;
#define OS_SYS_NS_PER_SECOND 1000000000
+#define OS_SYS_NS_PER_MS 1000000
+
#define OS_SYS_NS_PER_US 1000
#define OS_CYCLE_PER_TICK (g_sysClock / LOSCFG_BASE_CORE_TICK_PER_SECOND)
@@ -359,6 +361,63 @@ extern UINT32 LOS_MS2Tick(UINT32 millisec);
*/
extern UINT32 LOS_TickTimerRegister(const ArchTickTimer *timer, const HWI_PROC_FUNC tickHandler);
+/* *
+ * @ingroup los_task
+ * @brief: cpu delay.
+ *
+ * @par Description:
+ * This API is used to cpu delay, no task switching.
+ *
+ * @attention:
+ *
+ *
+ * @param UINT64 [IN] delay times, microseconds.
+ *
+ * @retval: None.
+ * @par Dependency:
+ * - los_task.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern VOID LOS_UDelay(UINT64 microseconds);
+
+/* *
+ * @ingroup los_task
+ * @brief: cpu delay.
+ *
+ * @par Description:
+ * This API is used to cpu delay, no task switching.
+ *
+ * @attention:
+ *
+ *
+ * @param UINT32 [IN] delay times, millisecond.
+ *
+ * @retval: None.
+ * @par Dependency:
+ * - los_task.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern VOID LOS_MDelay(UINT32 millisec);
+
+/* *
+ * @ingroup los_task
+ * @brief: cpu nanosecond get.
+ *
+ * @par Description:
+ * This API is used to get the current number of nanoseconds.
+ *
+ * @attention:
+ *
+ *
+ * @param none.
+ *
+ * @retval: None.
+ * @par Dependency:
+ * - los_task.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern UINT64 LOS_CurrNanosec(VOID);
+
/**
* @ingroup los_tick
* @brief Handle the system tick timeout.
@@ -407,6 +466,8 @@ typedef struct TagCpuTick {
*/
#define OS_SYS_US_PER_SECOND 1000000
+#define OS_SYS_US_PER_MS 1000
+
/**
* @ingroup los_tick
* The maximum length of name.
diff --git a/kernel/src/los_mux.c b/kernel/src/los_mux.c
index 41f64550..868b6908 100644
--- a/kernel/src/los_mux.c
+++ b/kernel/src/los_mux.c
@@ -165,7 +165,7 @@ STATIC_INLINE UINT32 OsMuxValidCheck(LosMuxCB *muxPended)
}
if (OS_INT_ACTIVE) {
- return LOS_ERRNO_MUX_PEND_INTERR;
+ return LOS_ERRNO_MUX_IN_INTERR;
}
if (g_losTaskLock) {
@@ -279,6 +279,11 @@ LITE_OS_SEC_TEXT UINT32 LOS_MuxPost(UINT32 muxHandle)
OS_RETURN_ERROR(LOS_ERRNO_MUX_INVALID);
}
+ if (OS_INT_ACTIVE) {
+ LOS_IntRestore(intSave);
+ OS_RETURN_ERROR(LOS_ERRNO_MUX_IN_INTERR);
+ }
+
runningTask = (LosTaskCB *)g_losTask.runTask;
if ((muxPosted->muxCount == 0) || (muxPosted->owner != runningTask)) {
LOS_IntRestore(intSave);
diff --git a/kernel/src/los_queue.c b/kernel/src/los_queue.c
index 12f45069..5d64248c 100644
--- a/kernel/src/los_queue.c
+++ b/kernel/src/los_queue.c
@@ -90,7 +90,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsQueueInit(VOID)
Output : queueID --- Queue ID
Return : LOS_OK on success or error code on failure
*****************************************************************************/
-LITE_OS_SEC_TEXT_INIT UINT32 LOS_QueueCreate(CHAR *queueName,
+LITE_OS_SEC_TEXT_INIT UINT32 LOS_QueueCreate(const CHAR *queueName,
UINT16 len,
UINT32 *queueID,
UINT32 flags,
@@ -234,9 +234,9 @@ static INLINE VOID OsQueueBufferOperate(LosQueueCB *queueCB, UINT32 operateType,
if (OS_QUEUE_IS_POINT(operateType)) {
if (OS_QUEUE_IS_READ(operateType)) {
- *(UINT32 *)bufferAddr = *(UINT32 *)(VOID *)queueNode;
+ *(UINTPTR *)bufferAddr = *(UINTPTR *)(VOID *)queueNode;
} else {
- *(UINT32 *)(VOID *)queueNode = *(UINT32 *)bufferAddr; // change to pp when calling OsQueueOperate
+ *(UINTPTR *)(VOID *)queueNode = *(UINTPTR *)bufferAddr;
}
} else {
if (OS_QUEUE_IS_READ(operateType)) {
@@ -271,6 +271,10 @@ static INLINE UINT32 OsQueueOperateParamCheck(const LosQueueCB *queueCB, UINT32
return LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG;
}
+ if (*bufferSize >= SECUREC_MEM_MAX_LEN) {
+ return LOS_ERRNO_QUEUE_BUFFER_SIZE_TOO_BIG;
+ }
+
return LOS_OK;
}
diff --git a/kernel/src/los_task.c b/kernel/src/los_task.c
index 50d08f5a..ec110c97 100644
--- a/kernel/src/los_task.c
+++ b/kernel/src/los_task.c
@@ -1486,19 +1486,7 @@ LITE_OS_SEC_TEXT_MINOR VOID LOS_Msleep(UINT32 mSecs)
(VOID)LOS_TaskDelay(interval);
}
-VOID LOS_UDelay(UINT64 microseconds)
+VOID LOS_TaskResRecycle(VOID)
{
- UINT64 endTime;
-
- if (microseconds == 0) {
- return;
- }
-
- endTime = (microseconds / OS_SYS_US_PER_SECOND) * g_sysClock +
- (microseconds % OS_SYS_US_PER_SECOND) * g_sysClock / OS_SYS_US_PER_SECOND;
- endTime = LOS_SysCycleGet() + endTime;
- while (LOS_SysCycleGet() < endTime) {
- }
-
- return;
+ OsRecyleFinishedTask();
}
diff --git a/kernel/src/los_tick.c b/kernel/src/los_tick.c
index 5e488868..37d28fd6 100644
--- a/kernel/src/los_tick.c
+++ b/kernel/src/los_tick.c
@@ -36,6 +36,7 @@
#include "los_swtmr.h"
#include "los_sched.h"
#include "los_debug.h"
+#include "stdint.h"
LITE_OS_SEC_BSS STATIC ArchTickTimer *g_sysTickTimer = NULL;
LITE_OS_SEC_BSS UINT32 g_ticksPerSec;
@@ -347,3 +348,58 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsCpuTick2US(CpuTick *cpuTick, UINT32 *usHi, UINT32
return LOS_OK;
}
+
+/*****************************************************************************
+Function : LOS_MS2Tick
+Description : get current nanoseconds
+Input : None
+Output : None
+Return : nanoseconds
+*****************************************************************************/
+UINT64 LOS_CurrNanosec(VOID)
+{
+ UINT64 nanos;
+ nanos = LOS_SysCycleGet() * (OS_SYS_NS_PER_SECOND / OS_SYS_NS_PER_MS) / (g_sysClock / OS_SYS_NS_PER_MS);
+ return nanos;
+}
+
+/*****************************************************************************
+Function : LOS_UDelay
+Description : cpu delay function
+Input : microseconds ---------- microseconds
+Output : None
+Return : None
+*****************************************************************************/
+VOID LOS_UDelay(UINT64 microseconds)
+{
+ UINT64 endTime;
+
+ if (microseconds == 0) {
+ return;
+ }
+
+ endTime = (microseconds / OS_SYS_US_PER_SECOND) * g_sysClock +
+ (microseconds % OS_SYS_US_PER_SECOND) * g_sysClock / OS_SYS_US_PER_SECOND;
+ endTime = LOS_SysCycleGet() + endTime;
+ while (LOS_SysCycleGet() < endTime) {
+ }
+ return;
+}
+
+/*****************************************************************************
+Function : LOS_MDelay
+Description : cpu delay function
+Input : millisec ---------- milliseconds
+Output : None
+Return : None
+*****************************************************************************/
+VOID LOS_MDelay(UINT32 millisec)
+{
+ UINT32 delayUs = (UINT32_MAX / OS_SYS_US_PER_MS) * OS_SYS_US_PER_MS;
+ while (millisec > UINT32_MAX / OS_SYS_US_PER_MS) {
+ LOS_UDelay(delayUs);
+ millisec -= (UINT32_MAX / OS_SYS_US_PER_MS);
+ }
+ LOS_UDelay(millisec * OS_SYS_US_PER_MS);
+ return;
+}
diff --git a/kernel/src/mm/los_memory.c b/kernel/src/mm/los_memory.c
index 30a75486..9794d810 100644
--- a/kernel/src/mm/los_memory.c
+++ b/kernel/src/mm/los_memory.c
@@ -1037,24 +1037,24 @@ STATIC UINT32 OsMemPoolDelete(VOID *pool)
UINT32 LOS_MemInit(VOID *pool, UINT32 size)
{
if ((pool == NULL) || (size <= OS_MEM_MIN_POOL_SIZE)) {
- return OS_ERROR;
+ return LOS_NOK;
}
if (((UINTPTR)pool & (OS_MEM_ALIGN_SIZE - 1)) || \
(size & (OS_MEM_ALIGN_SIZE - 1))) {
PRINT_ERR("LiteOS heap memory address or size configured not aligned:address:0x%x,size:0x%x, alignsize:%d\n", \
(UINTPTR)pool, size, OS_MEM_ALIGN_SIZE);
- return OS_ERROR;
+ return LOS_NOK;
}
if (OsMemPoolInit(pool, size)) {
- return OS_ERROR;
+ return LOS_NOK;
}
#if (LOSCFG_MEM_MUL_POOL == 1)
if (OsMemPoolAdd(pool, size)) {
(VOID)OsMemPoolDeinit(pool);
- return OS_ERROR;
+ return LOS_NOK;
}
#endif
@@ -1067,11 +1067,11 @@ UINT32 LOS_MemInit(VOID *pool, UINT32 size)
UINT32 LOS_MemDeInit(VOID *pool)
{
if (pool == NULL) {
- return OS_ERROR;
+ return LOS_NOK;
}
if (OsMemPoolDelete(pool)) {
- return OS_ERROR;
+ return LOS_NOK;
}
OsMemPoolDeinit(pool);
@@ -1593,11 +1593,11 @@ UINT32 LOS_MemFreeByTaskID(VOID *pool, UINT32 taskID)
{
UINT32 args[2] = { taskID, (UINT32)(UINTPTR)pool };
if (pool == NULL) {
- return OS_ERROR;
+ return LOS_NOK;
}
if (taskID >= LOSCFG_BASE_CORE_TSK_LIMIT) {
- return OS_ERROR;
+ return LOS_NOK;
}
OsAllMemNodeDoHandle(pool, MemNodeFreeByTaskIDHandle, (VOID *)args);
diff --git a/testsuites/sample/kernel/hwi/BUILD.gn b/testsuites/sample/kernel/hwi/BUILD.gn
index 97ce9918..11f11e20 100644
--- a/testsuites/sample/kernel/hwi/BUILD.gn
+++ b/testsuites/sample/kernel/hwi/BUILD.gn
@@ -64,6 +64,11 @@ static_library("test_hwi") {
"it_los_hwi_032.c",
"it_los_hwi_033.c",
"it_los_hwi_034.c",
+ "it_los_hwi_036.c",
+ "it_los_hwi_037.c",
+ "it_los_hwi_038.c",
+ "it_los_hwi_039.c",
+ "it_los_hwi_040.c",
"llt_los_hwi_035.c",
]
diff --git a/testsuites/sample/kernel/hwi/It_los_hwi.c b/testsuites/sample/kernel/hwi/It_los_hwi.c
index d1225569..b0b56631 100644
--- a/testsuites/sample/kernel/hwi/It_los_hwi.c
+++ b/testsuites/sample/kernel/hwi/It_los_hwi.c
@@ -57,6 +57,11 @@ VOID ItSuiteLosHwi()
ItLosHwi030();
ItLosHwi031();
ItLosHwi034();
+ ItLosHwi036();
+ ItLosHwi037();
+ ItLosHwi038();
+ ItLosHwi039();
+ ItLosHwi040();
#if (LOS_KERNEL_MULTI_HWI_TEST == 1)
ItLosHwi003();
ItLosHwi005();
diff --git a/testsuites/sample/kernel/hwi/it_los_hwi.h b/testsuites/sample/kernel/hwi/it_los_hwi.h
index 45e7dff2..dbbc68b6 100644
--- a/testsuites/sample/kernel/hwi/it_los_hwi.h
+++ b/testsuites/sample/kernel/hwi/it_los_hwi.h
@@ -73,6 +73,12 @@ extern VOID ItLosHwi030(VOID);
extern VOID ItLosHwi031(VOID);
extern VOID ItLosHwi034(VOID);
extern VOID LltLosHwi035(VOID);
+extern VOID ItLosHwi036(VOID);
+extern VOID ItLosHwi037(VOID);
+extern VOID ItLosHwi038(VOID);
+extern VOID ItLosHwi039(VOID);
+extern VOID ItLosHwi040(VOID);
+
#if (LOS_KERNEL_MULTI_HWI_TEST == 1)
extern VOID ItLosHwi003(VOID);
diff --git a/testsuites/sample/kernel/hwi/it_los_hwi_036.c b/testsuites/sample/kernel/hwi/it_los_hwi_036.c
new file mode 100644
index 00000000..213c85cb
--- /dev/null
+++ b/testsuites/sample/kernel/hwi/it_los_hwi_036.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "osTest.h"
+#include "it_los_hwi.h"
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 intSave;
+ UINT32 deltaTicks;
+ UINT64 timeRecordNS;
+ UINT64 timeUpdateNS;
+ UINT64 delayMs = 10; // delay 10 MS
+ UINT32 deltaMs;
+ UINT64 delayTicks;
+ UINT32 loop = 10; // loop 10 time
+ delayTicks = delayMs * LOSCFG_BASE_CORE_TICK_PER_SECOND / OS_SYS_MS_PER_SECOND;
+
+ for (int i = 0; i <= loop; i++, delayTicks++) {
+ timeRecordNS = LOS_CurrNanosec();
+ LOS_TaskDelay(delayTicks);
+ timeUpdateNS = LOS_CurrNanosec();
+ deltaTicks = ((timeUpdateNS - timeRecordNS) * LOSCFG_BASE_CORE_TICK_PER_SECOND / OS_SYS_NS_PER_SECOND);
+
+ if (deltaTicks >= (delayTicks - 1) && deltaTicks <= (delayTicks + 1)) {
+ continue;
+ } else {
+ ICUNIT_ASSERT_EQUAL(deltaTicks, delayTicks, deltaTicks);
+ }
+ }
+
+ intSave = LOS_IntLock();
+ for (int i = 1; i <= loop; i++) {
+ timeRecordNS = LOS_CurrNanosec();
+ LOS_MDelay(i);
+ timeUpdateNS = LOS_CurrNanosec();
+ deltaMs = (timeUpdateNS - timeRecordNS) / OS_SYS_NS_PER_MS;
+ ICUNIT_ASSERT_EQUAL(deltaMs, i, deltaMs);
+ }
+ LOS_IntRestore(intSave);
+
+ return LOS_OK;
+}
+
+VOID ItLosHwi036(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosHwi036", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/sample/kernel/hwi/it_los_hwi_037.c b/testsuites/sample/kernel/hwi/it_los_hwi_037.c
new file mode 100644
index 00000000..5e72564a
--- /dev/null
+++ b/testsuites/sample/kernel/hwi/it_los_hwi_037.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "osTest.h"
+#include "it_los_hwi.h"
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 intSave;
+ UINT64 timeRecordNS;
+ UINT64 timeUpdateNS;
+ UINT32 deltaMs;
+ UINT32 loop = 10; // loop 10 time
+
+ intSave = LOS_IntLock();
+ for (int i = 1; i <= loop; i++) {
+ timeRecordNS = LOS_CurrNanosec();
+ LOS_MDelay(i);
+ timeUpdateNS = LOS_CurrNanosec();
+ deltaMs = (timeUpdateNS - timeRecordNS) / OS_SYS_NS_PER_MS;
+ ICUNIT_ASSERT_EQUAL(deltaMs, i, deltaMs);
+ }
+ LOS_IntRestore(intSave);
+
+ return LOS_OK;
+}
+
+VOID ItLosHwi037(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosHwi037", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/sample/kernel/hwi/it_los_hwi_038.c b/testsuites/sample/kernel/hwi/it_los_hwi_038.c
new file mode 100644
index 00000000..b7fd6a24
--- /dev/null
+++ b/testsuites/sample/kernel/hwi/it_los_hwi_038.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "osTest.h"
+#include "it_los_hwi.h"
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 deltaTicks;
+ UINT64 timeRecordNS;
+ UINT64 timeUpdateNS;
+ UINT64 tickRecord;
+ UINT64 tickUpdate;
+ UINT32 loop = 10; // loop 10 time.
+
+ timeRecordNS = LOS_CurrNanosec();
+ tickRecord = LOS_TickCountGet();
+ LOS_TaskDelay(1);
+ for (int i = 1; i <= loop; i++) {
+ LOS_MDelay(i * 10); // i * 10, Set delay time.
+ timeUpdateNS = LOS_CurrNanosec();
+ tickUpdate = LOS_TickCountGet();
+ deltaTicks = (UINT32)((timeUpdateNS - timeRecordNS) * LOSCFG_BASE_CORE_TICK_PER_SECOND / OS_SYS_NS_PER_SECOND);
+ ICUNIT_ASSERT_WITHIN_EQUAL(deltaTicks, tickUpdate - tickRecord - 1, tickUpdate - tickRecord + 1, deltaTicks);
+ }
+
+ return LOS_OK;
+}
+
+VOID ItLosHwi038(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosHwi038", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/sample/kernel/hwi/it_los_hwi_039.c b/testsuites/sample/kernel/hwi/it_los_hwi_039.c
new file mode 100755
index 00000000..d0b929f3
--- /dev/null
+++ b/testsuites/sample/kernel/hwi/it_los_hwi_039.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "osTest.h"
+#include "it_los_hwi.h"
+
+static VOID HwiF01(VOID)
+{
+ TestHwiClear(HWI_NUM_TEST);
+ g_testCount++;
+
+EXIT:
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ HWI_PRIOR_T hwiPrio = 2;
+ HWI_MODE_T mode = 0;
+ HWI_ARG_T arg = 0;
+
+ g_testCount = 0;
+ ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, arg);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_HwiDisable(HWI_NUM_TEST);
+ TestHwiTrigger(HWI_NUM_TEST);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); // Compare wiht the expected value 0.
+
+ LOS_HwiEnable(HWI_NUM_TEST);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); // Compare wiht the expected value 1.
+
+ TestHwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+
+EXIT:
+ TestHwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+VOID ItLosHwi039(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosHwi039", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/sample/kernel/hwi/it_los_hwi_040.c b/testsuites/sample/kernel/hwi/it_los_hwi_040.c
new file mode 100755
index 00000000..79e54c19
--- /dev/null
+++ b/testsuites/sample/kernel/hwi/it_los_hwi_040.c
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "osTest.h"
+#include "it_los_hwi.h"
+
+static UINT32 TesttriggerIrq(HWI_HANDLE_T hwiNum)
+{
+ g_testCount++;
+ printf("This is TesttriggerIrq\n");
+ return LOS_OK;
+}
+
+static UINT32 TestclearIrq(HWI_HANDLE_T hwiNum)
+{
+ g_testCount++;
+ printf("This is TestclearIrq\n");
+ return LOS_OK;
+}
+
+static UINT32 TestenableIrq(HWI_HANDLE_T hwiNum)
+{
+ g_testCount++;
+ printf("This is TestenableIrq\n");
+ return LOS_OK;
+}
+
+static UINT32 TestdisableIrq(HWI_HANDLE_T hwiNum)
+{
+ g_testCount++;
+ printf("This is TestdisableIrq\n");
+ return LOS_OK;
+}
+
+static UINT32 TestsetIrqPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
+{
+ g_testCount++;
+ printf("This is TestsetIrqPriority\n");
+ return LOS_OK;
+}
+
+static UINT32 TestgetCurIrqNum(VOID)
+{
+ g_testCount++;
+ printf("This is TestgetCurIrqNum\n");
+ return HWI_NUM_TEST;
+}
+
+static VOID HwiF01(VOID)
+{
+ TestHwiClear(HWI_NUM_TEST);
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret = LOS_OK;
+ UINT32 irqNum = 0;
+ HWI_PRIOR_T hwiPrio = 2; // 2, Set hwi priority.
+ HWI_MODE_T mode = 0;
+ HWI_ARG_T arg = 0;
+ HwiControllerOps *ops = NULL;
+ HwiControllerOps *opsBac = (HwiControllerOps *)malloc(sizeof(HwiControllerOps));
+ if (opsBac == NULL) {
+ ret = LOS_NOK;
+ }
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ (VOID)memset_s(opsBac, sizeof(HwiControllerOps), 0, sizeof(HwiControllerOps));
+
+ g_testCount = 0;
+ ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, arg);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiTrigger(LOSCFG_PLATFORM_HWI_LIMIT + 1);
+ ICUNIT_ASSERT_EQUAL(ret, OS_ERRNO_HWI_NUM_INVALID, ret);
+ ret = LOS_HwiEnable(LOSCFG_PLATFORM_HWI_LIMIT + 1);
+ ICUNIT_ASSERT_EQUAL(ret, OS_ERRNO_HWI_NUM_INVALID, ret);
+ ret = LOS_HwiDisable(LOSCFG_PLATFORM_HWI_LIMIT + 1);
+ ICUNIT_ASSERT_EQUAL(ret, OS_ERRNO_HWI_NUM_INVALID, ret);
+ ret = LOS_HwiClear(LOSCFG_PLATFORM_HWI_LIMIT + 1);
+ ICUNIT_ASSERT_EQUAL(ret, OS_ERRNO_HWI_NUM_INVALID, ret);
+ hwiPrio = 3; // 3, Set hwi priority.
+ ret = LOS_HwiSetPriority(LOSCFG_PLATFORM_HWI_LIMIT + 1, hwiPrio);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ops = LOS_HwiOpsGet();
+ (VOID)memcpy_s(opsBac, sizeof(HwiControllerOps), ops, sizeof(HwiControllerOps));
+ ops->triggerIrq = TesttriggerIrq;
+ ops->enableIrq = TestenableIrq;
+ ops->disableIrq = TestdisableIrq;
+ ops->setIrqPriority = TestsetIrqPriority;
+ ops->getCurIrqNum = TestgetCurIrqNum;
+ ops->clearIrq = TestclearIrq;
+
+ LOS_HwiTrigger(HWI_NUM_TEST);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); // Compare wiht the expected value 1.
+ LOS_HwiEnable(HWI_NUM_TEST);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // Compare wiht the expected value 2.
+ LOS_HwiDisable(HWI_NUM_TEST);
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // Compare wiht the expected value 3.
+ LOS_HwiClear(HWI_NUM_TEST);
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // Compare wiht the expected value 4.
+ LOS_HwiSetPriority(HWI_NUM_TEST, 3); // 3, Set hwi priority.
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // Compare wiht the expected value 5.
+ irqNum = LOS_HwiCurIrqNum();
+ ICUNIT_ASSERT_EQUAL(irqNum, HWI_NUM_TEST, irqNum);
+ ICUNIT_GOTO_EQUAL(g_testCount, 6, g_testCount, EXIT); // Compare wiht the expected value 6.
+
+ ops->triggerIrq = opsBac->triggerIrq;
+ ops->enableIrq = opsBac->enableIrq;
+ ops->disableIrq = opsBac->disableIrq;
+ ops->setIrqPriority = opsBac->setIrqPriority;
+ ops->getCurIrqNum = opsBac->getCurIrqNum;
+ ops->clearIrq = opsBac->clearIrq;
+
+ free(opsBac);
+ ret = LOS_HwiDisable(HWI_NUM_TEST);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_HwiTrigger(HWI_NUM_TEST);
+ ICUNIT_GOTO_EQUAL(g_testCount, 6, g_testCount, EXIT); // Compare wiht the expected value 6.
+ ret = LOS_HwiEnable(HWI_NUM_TEST);
+ ICUNIT_GOTO_EQUAL(g_testCount, 7, g_testCount, EXIT); // Compare wiht the expected value 7.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_HwiTrigger(HWI_NUM_TEST);
+ ICUNIT_GOTO_EQUAL(g_testCount, 8, g_testCount, EXIT); // Compare wiht the expected value 8.
+
+ TestHwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+
+EXIT:
+ TestHwiDelete(HWI_NUM_TEST);
+ free(opsBac);
+ return LOS_OK;
+}
+
+VOID ItLosHwi040(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosHwi040", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/sample/kernel/mem/It_los_mem_004.c b/testsuites/sample/kernel/mem/It_los_mem_004.c
index 959720b1..76b4c091 100644
--- a/testsuites/sample/kernel/mem/It_los_mem_004.c
+++ b/testsuites/sample/kernel/mem/It_los_mem_004.c
@@ -38,10 +38,10 @@ static UINT32 TestCase(VOID)
UINT32 ret;
ret = LOS_MemInit(NULL, TEST_MEM_SIZE);
- ICUNIT_ASSERT_EQUAL(ret, OS_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_NOK, ret);
ret = LOS_MemInit(g_memPool, MIN_MEM_POOL_SIZE - 1);
- ICUNIT_ASSERT_EQUAL(ret, OS_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_NOK, ret);
return LOS_OK;
}
diff --git a/testsuites/sample/kernel/mux/It_los_mutex_013.c b/testsuites/sample/kernel/mux/It_los_mutex_013.c
index cec4f465..ca126008 100644
--- a/testsuites/sample/kernel/mux/It_los_mutex_013.c
+++ b/testsuites/sample/kernel/mux/It_los_mutex_013.c
@@ -43,14 +43,14 @@ static VOID HwiF01(void)
ret = LOS_MuxPend(g_mutexTest, 0);
- ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret);
ret = LOS_MuxPend(g_mutexTest, LOS_WAIT_FOREVER);
- ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret);
ret = LOS_MuxPost(g_mutexTest);
- ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_INVALID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret);
ret = LOS_MuxDelete(g_mutexTest);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
diff --git a/testsuites/sample/kernel/mux/It_los_mutex_016.c b/testsuites/sample/kernel/mux/It_los_mutex_016.c
index 1ee32b29..5d27eca1 100644
--- a/testsuites/sample/kernel/mux/It_los_mutex_016.c
+++ b/testsuites/sample/kernel/mux/It_los_mutex_016.c
@@ -40,7 +40,7 @@ static VOID HwiF01(void)
TestHwiClear(HWI_NUM_TEST);
ret = LOS_MuxPost(g_mutexTest);
- ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret);
g_testCount++;
}
@@ -65,7 +65,7 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount); // 1, Here, assert that g_testCount is equal to 1.
ret = LOS_MuxPost(g_mutexTest);
- ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_MUX_INVALID, ret);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
ret = LOS_MuxDelete(g_mutexTest);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
diff --git a/testsuites/sample/kernel/mux/It_los_mutex_017.c b/testsuites/sample/kernel/mux/It_los_mutex_017.c
index 7287168c..3462021d 100644
--- a/testsuites/sample/kernel/mux/It_los_mutex_017.c
+++ b/testsuites/sample/kernel/mux/It_los_mutex_017.c
@@ -40,7 +40,7 @@ static VOID HwiF01(void)
TestHwiClear(HWI_NUM_TEST);
ret = LOS_MuxPost(g_mutexTest);
- ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret);
g_testCount++;
}
@@ -64,7 +64,7 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount); // 1, Here, assert that g_testCount is equal to 1.
ret = LOS_MuxPost(g_mutexTest);
- ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_MUX_INVALID, ret);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
ret = LOS_MuxDelete(g_mutexTest);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
diff --git a/testsuites/sample/kernel/mux/It_los_mutex_019.c b/testsuites/sample/kernel/mux/It_los_mutex_019.c
index 060d749a..41e4f055 100644
--- a/testsuites/sample/kernel/mux/It_los_mutex_019.c
+++ b/testsuites/sample/kernel/mux/It_los_mutex_019.c
@@ -46,15 +46,15 @@ static VOID Func01(void)
TestHwiDelete(HWI_NUM_TEST);
} else if (g_testCount == 3) { // 3, Here, The current possible value of the variable.
- ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret);
}
ret = LOS_MuxPost(g_mutexTest);
if (g_testCount == 3) { // 3, Here, The current possible value of the variable.
- ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret);
} else if (g_testCount == 4) { // 4, Here, The current possible value of the variable.
- ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_INVALID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
}
g_testCount++;
@@ -64,7 +64,7 @@ static VOID HwiF01(void)
{
TestHwiClear(HWI_NUM_TEST);
- ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
g_testCount++;
diff --git a/testsuites/sample/kernel/mux/It_los_mutex_020.c b/testsuites/sample/kernel/mux/It_los_mutex_020.c
index 28e49ed2..e46ce160 100644
--- a/testsuites/sample/kernel/mux/It_los_mutex_020.c
+++ b/testsuites/sample/kernel/mux/It_los_mutex_020.c
@@ -45,7 +45,7 @@ static VOID HwiF02(void)
g_testCount++;
ret = LOS_MuxPost(g_mutexTest);
- ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_INVALID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret);
}
static VOID HwiF01(void)
@@ -57,7 +57,7 @@ static VOID HwiF01(void)
g_testCount++;
ret = LOS_MuxPend(g_mutexTest, LOS_WAIT_FOREVER);
- ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret);
ret = LOS_HwiCreate(HWI_NUM_TEST0, 1, 0, (HWI_PROC_FUNC)HwiF02, 0);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
diff --git a/testsuites/sample/kernel/queue/It_los_queue_021.c b/testsuites/sample/kernel/queue/It_los_queue_021.c
index b1530cec..f3835d78 100644
--- a/testsuites/sample/kernel/queue/It_los_queue_021.c
+++ b/testsuites/sample/kernel/queue/It_los_queue_021.c
@@ -45,10 +45,10 @@ static UINT32 Testcase(VOID)
ret = LOS_QueueCreate(NULL, QUEUE_BASE_NUM, &queueID[index], 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
}
- ret = LOS_QueueWrite(LOSCFG_BASE_IPC_QUEUE_LIMIT - 1, &buff1, QUEUE_BASE_MSGSIZE, 0);
+ ret = LOS_QueueWrite(queueID[limit - 1], &buff1, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
- ret = LOS_QueueRead(LOSCFG_BASE_IPC_QUEUE_LIMIT - 1, &buff2, QUEUE_BASE_MSGSIZE, 0);
+ ret = LOS_QueueRead(queueID[limit - 1], &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &queueID[index], 0, QUEUE_BASE_MSGSIZE);
diff --git a/testsuites/sample/kernel/queue/It_los_queue_030.c b/testsuites/sample/kernel/queue/It_los_queue_030.c
index fd54328b..89a9494e 100644
--- a/testsuites/sample/kernel/queue/It_los_queue_030.c
+++ b/testsuites/sample/kernel/queue/It_los_queue_030.c
@@ -46,11 +46,11 @@ static UINT32 Testcase(VOID)
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
}
// 2, is test for LOSCFG_BASE_IPC_QUEUE_LIMIT - 2
- ret = LOS_QueueWrite(LOSCFG_BASE_IPC_QUEUE_LIMIT - 2, &buff1, QUEUE_BASE_MSGSIZE, 0);
+ ret = LOS_QueueWrite(queueID[limit - 1], &buff1, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
// 2, is test for LOSCFG_BASE_IPC_QUEUE_LIMIT - 2
- ret = LOS_QueueRead(LOSCFG_BASE_IPC_QUEUE_LIMIT - 2, &buff2, QUEUE_BASE_MSGSIZE, 0);
+ ret = LOS_QueueRead(queueID[limit - 1], &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
EXIT:
diff --git a/testsuites/sample/kernel/queue/It_los_queue_065.c b/testsuites/sample/kernel/queue/It_los_queue_065.c
index d8c79375..b8f96573 100644
--- a/testsuites/sample/kernel/queue/It_los_queue_065.c
+++ b/testsuites/sample/kernel/queue/It_los_queue_065.c
@@ -45,8 +45,7 @@ static UINT32 Testcase(VOID)
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
ret = LOS_QueueRead(g_testQueueID01, &buff2, 0xffffffff, 0);
- ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
- ICUNIT_GOTO_EQUAL(*((char *)(intptr_t)buff2 + 7), buff1[7], *((char *)(intptr_t)buff2 + 7), EXIT); // 7, QUEUE_BASE_MSGSIZE - 1
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_BUFFER_SIZE_TOO_BIG, ret, EXIT);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
diff --git a/testsuites/sample/kernel/queue/It_los_queue_066.c b/testsuites/sample/kernel/queue/It_los_queue_066.c
index 832e3544..3b424246 100644
--- a/testsuites/sample/kernel/queue/It_los_queue_066.c
+++ b/testsuites/sample/kernel/queue/It_los_queue_066.c
@@ -45,8 +45,7 @@ static UINT32 Testcase(VOID)
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
ret = LOS_QueueRead(g_testQueueID01, &buff2, (0xffffffff - 1), 0);
- ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
- ICUNIT_GOTO_EQUAL(*((char *)(intptr_t)buff2 + 7), buff1[7], *((char *)(intptr_t)buff2 + 7), EXIT); // 7, Verify that the data is correct
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_BUFFER_SIZE_TOO_BIG, ret, EXIT);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
diff --git a/testsuites/sample/kernel/queue/It_los_queue_head_015.c b/testsuites/sample/kernel/queue/It_los_queue_head_015.c
index 484acd92..1c6db5fe 100644
--- a/testsuites/sample/kernel/queue/It_los_queue_head_015.c
+++ b/testsuites/sample/kernel/queue/It_los_queue_head_015.c
@@ -46,10 +46,10 @@ static UINT32 Testcase(VOID)
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
}
- ret = LOS_QueueWriteHead(LOSCFG_BASE_IPC_QUEUE_LIMIT - 1, &buff1, QUEUE_BASE_MSGSIZE, 0);
+ ret = LOS_QueueWriteHead(queueID[limit - 1], &buff1, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
- ret = LOS_QueueRead(LOSCFG_BASE_IPC_QUEUE_LIMIT - 1, &buff2, QUEUE_BASE_MSGSIZE, 0);
+ ret = LOS_QueueRead(queueID[limit - 1], &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &queueID[index], 0, QUEUE_BASE_MSGSIZE);
diff --git a/testsuites/sample/kernel/queue/It_los_queue_head_022.c b/testsuites/sample/kernel/queue/It_los_queue_head_022.c
index 053a9cda..64380c24 100644
--- a/testsuites/sample/kernel/queue/It_los_queue_head_022.c
+++ b/testsuites/sample/kernel/queue/It_los_queue_head_022.c
@@ -46,10 +46,10 @@ static UINT32 Testcase(VOID)
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
}
- ret = LOS_QueueWriteHead(LOSCFG_BASE_IPC_QUEUE_LIMIT - 1, &buff1, QUEUE_BASE_MSGSIZE, 0);
+ ret = LOS_QueueWriteHead(queueID[limit - 1], &buff1, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
- ret = LOS_QueueRead(LOSCFG_BASE_IPC_QUEUE_LIMIT - 1, &buff2, QUEUE_BASE_MSGSIZE, 0);
+ ret = LOS_QueueRead(queueID[limit - 1], &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
EXIT:
diff --git a/testsuites/sample/kernel/swtmr/BUILD.gn b/testsuites/sample/kernel/swtmr/BUILD.gn
index 4afcd483..7acd3db1 100644
--- a/testsuites/sample/kernel/swtmr/BUILD.gn
+++ b/testsuites/sample/kernel/swtmr/BUILD.gn
@@ -107,6 +107,8 @@ static_library("test_swtmr") {
"It_los_swtmr_077.c",
"It_los_swtmr_078.c",
"It_los_swtmr_079.c",
+ "It_los_swtmr_080.c",
+ "It_los_swtmr_081.c",
"It_los_swtmr_Align_001.c",
"It_los_swtmr_Align_002.c",
"It_los_swtmr_Align_003.c",
diff --git a/testsuites/sample/kernel/swtmr/It_los_swtmr.c b/testsuites/sample/kernel/swtmr/It_los_swtmr.c
index 8a6407e8..790f2226 100644
--- a/testsuites/sample/kernel/swtmr/It_los_swtmr.c
+++ b/testsuites/sample/kernel/swtmr/It_los_swtmr.c
@@ -114,6 +114,8 @@ VOID ItSuiteLosSwtmr(void)
ItLosSwtmr077();
ItLosSwtmr078();
ItLosSwtmr079();
+ ItLosSwtmr080();
+ ItLosSwtmr081();
#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
ItLosSwtmrAlign005();
ItLosSwtmrAlign006();
diff --git a/testsuites/sample/kernel/swtmr/It_los_swtmr.h b/testsuites/sample/kernel/swtmr/It_los_swtmr.h
index 58ce2b34..3fba7707 100644
--- a/testsuites/sample/kernel/swtmr/It_los_swtmr.h
+++ b/testsuites/sample/kernel/swtmr/It_los_swtmr.h
@@ -148,6 +148,8 @@ extern VOID ItLosSwtmr076(VOID);
extern VOID ItLosSwtmr077(VOID);
extern VOID ItLosSwtmr078(VOID);
extern VOID ItLosSwtmr079(VOID);
+extern VOID ItLosSwtmr080(VOID);
+extern VOID ItLosSwtmr081(VOID);
extern VOID ItLosSwtmrAlign001(VOID);
extern VOID ItLosSwtmrAlign002(VOID);
diff --git a/testsuites/sample/kernel/swtmr/It_los_swtmr_068.c b/testsuites/sample/kernel/swtmr/It_los_swtmr_068.c
index e3458851..e3a5f8e4 100644
--- a/testsuites/sample/kernel/swtmr/It_los_swtmr_068.c
+++ b/testsuites/sample/kernel/swtmr/It_los_swtmr_068.c
@@ -72,8 +72,8 @@ static UINT32 Testcase(VOID)
ret = LOS_SwtmrTimeGet(swTmrID, &tick);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
- // 2 - 1, Here, assert that uwTick is equal to this .
- ICUNIT_GOTO_EQUAL(tick, 2 - 1, tick, EXIT);
+ // 1, Here, assert that uwTick is equal to this .
+ ICUNIT_GOTO_EQUAL(tick, 1, tick, EXIT);
// 2, Here, assert that g_testCount is equal to this .
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT);
diff --git a/testsuites/sample/kernel/swtmr/It_los_swtmr_080.c b/testsuites/sample/kernel/swtmr/It_los_swtmr_080.c
new file mode 100644
index 00000000..8933e2af
--- /dev/null
+++ b/testsuites/sample/kernel/swtmr/It_los_swtmr_080.c
@@ -0,0 +1,87 @@
+/*
+ * 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 "osTest.h"
+#include "It_los_swtmr.h"
+
+static UINT32 g_testCount1 = 0;
+static VOID Case1(UINT32 arg)
+{
+ g_testCount1++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ g_testCount1 = 0;
+ UINT64 tickRecord;
+ UINT64 tickUpdate;
+ UINT64 delayTicks;
+ const UINT64 delayMs = 10; // delay 10 MS
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_PERIOD, Case1, &g_swtmrId1, 0xffff
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
+ , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE
+#endif
+ );
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(g_swtmrId1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ tickRecord = LOS_TickCountGet();
+ LOS_MDelay(delayMs);
+ tickUpdate = LOS_TickCountGet();
+
+ // 0, Here, assert that g_testCount is equal to this.
+ ICUNIT_ASSERT_EQUAL(g_testCount1, 0, g_testCount);
+
+ delayTicks = delayMs * LOSCFG_BASE_CORE_TICK_PER_SECOND / OS_SYS_MS_PER_SECOND;
+ ICUNIT_ASSERT_WITHIN_EQUAL(delayTicks, tickUpdate - tickRecord - 1, tickUpdate - tickRecord + 1, delayTicks);
+
+ // 10, set task delay time.
+ LOS_TaskDelay(10);
+
+ // 2, Here, assert that g_testCount is equal to this.
+ ICUNIT_ASSERT_EQUAL(g_testCount1, 2, g_testCount);
+
+EXIT:
+ LOS_SwtmrDelete(g_swtmrId1);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr080() // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr080", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
diff --git a/testsuites/sample/kernel/swtmr/It_los_swtmr_081.c b/testsuites/sample/kernel/swtmr/It_los_swtmr_081.c
new file mode 100644
index 00000000..587a8170
--- /dev/null
+++ b/testsuites/sample/kernel/swtmr/It_los_swtmr_081.c
@@ -0,0 +1,84 @@
+/*
+ * 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 "osTest.h"
+#include "It_los_swtmr.h"
+
+static UINT32 g_testCount1 = 0;
+static UINT64 g_timeRecordNS = 0;
+static UINT64 g_timeUpdateNS = 0;
+
+#define SWTMR_PERIODIC 4
+
+static VOID Case1(UINT32 arg)
+{
+ g_testCount1++;
+ g_timeUpdateNS = LOS_CurrNanosec();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ g_testCount1 = 0;
+ UINT64 tickRecord;
+ UINT64 tickUpdate;
+ UINT64 deltaTicks;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(SWTMR_PERIODIC, LOS_SWTMR_MODE_ONCE, Case1, &g_swtmrId1, 0xffff
+#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
+ , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE
+#endif
+ );
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ g_timeRecordNS = LOS_CurrNanosec();
+
+ ret = LOS_SwtmrStart(g_swtmrId1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ // 10, SSet task delay time.
+ LOS_TaskDelay(10);
+
+ deltaTicks = (g_timeUpdateNS - g_timeRecordNS) * LOSCFG_BASE_CORE_TICK_PER_SECOND / OS_SYS_NS_PER_SECOND;
+ ICUNIT_ASSERT_EQUAL(deltaTicks, SWTMR_PERIODIC, deltaTicks);
+
+EXIT:
+ LOS_SwtmrDelete(g_swtmrId1);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr081() // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr081", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
diff --git a/testsuites/sample/kernel/task/BUILD.gn b/testsuites/sample/kernel/task/BUILD.gn
index a78d11dd..47d0480f 100644
--- a/testsuites/sample/kernel/task/BUILD.gn
+++ b/testsuites/sample/kernel/task/BUILD.gn
@@ -150,6 +150,11 @@ static_library("test_task") {
"It_los_task_121.c",
"It_los_task_122.c",
"It_los_task_123.c",
+ "It_los_task_124.c",
+ "It_los_task_125.c",
+ "It_los_task_126.c",
+ "It_los_task_127.c",
+ "It_los_task_128.c",
]
configs += [ "//kernel/liteos_m/testsuites:include" ]
diff --git a/testsuites/sample/kernel/task/It_los_task.c b/testsuites/sample/kernel/task/It_los_task.c
index df85478b..d22df821 100644
--- a/testsuites/sample/kernel/task/It_los_task.c
+++ b/testsuites/sample/kernel/task/It_los_task.c
@@ -123,7 +123,11 @@ VOID ItSuiteLosTask()
ItLosTask121();
ItLosTask122();
ItLosTask123();
-
+ ItLosTask124();
+ ItLosTask125();
+ ItLosTask126();
+ ItLosTask127();
+ ItLosTask128();
#if (LOS_KERNEL_TEST_FULL == 1)
ItLosTask039();
ItLosTask040();
diff --git a/testsuites/sample/kernel/task/It_los_task.h b/testsuites/sample/kernel/task/It_los_task.h
index 6d18575b..13b92334 100644
--- a/testsuites/sample/kernel/task/It_los_task.h
+++ b/testsuites/sample/kernel/task/It_los_task.h
@@ -178,6 +178,11 @@ extern VOID ItLosTask120(VOID);
extern VOID ItLosTask121(VOID);
extern VOID ItLosTask122(VOID);
extern VOID ItLosTask123(VOID);
+extern VOID ItLosTask124(VOID);
+extern VOID ItLosTask125(VOID);
+extern VOID ItLosTask126(VOID);
+extern VOID ItLosTask127(VOID);
+extern VOID ItLosTask128(VOID);
#ifdef __cplusplus
#if __cplusplus
diff --git a/testsuites/sample/kernel/task/It_los_task_124.c b/testsuites/sample/kernel/task/It_los_task_124.c
new file mode 100644
index 00000000..6eb35996
--- /dev/null
+++ b/testsuites/sample/kernel/task/It_los_task_124.c
@@ -0,0 +1,90 @@
+/*
+ * 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 "osTest.h"
+#include "It_los_task.h"
+
+static UINT32 GetfreeMemSize(void *pool)
+{
+ return LOS_MemPoolSizeGet(pool) - LOS_MemTotalUsedGet(pool);
+}
+
+static VOID TaskF01(UINT32 arg)
+{
+ g_testCount++;
+ return;
+}
+
+static UINT32 TestCase(VOID)
+{
+ UINT32 freeMem;
+ UINT32 freeMem1;
+ UINT32 freeMem2;
+ UINT32 freeMem3;
+ UINT32 freeMem4;
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk124A";
+ task1.usTaskPrio = 8; // 8, set task priortiy value.
+ g_testCount = 0;
+
+ freeMem = GetfreeMemSize(m_aucSysMem0);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ freeMem1 = GetfreeMemSize(m_aucSysMem0);
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ freeMem2 = GetfreeMemSize(m_aucSysMem0);
+ ICUNIT_ASSERT_EQUAL(freeMem2, freeMem1, freeMem2);
+
+ LOS_TaskResRecycle();
+ freeMem3 = GetfreeMemSize(m_aucSysMem0);
+ ICUNIT_ASSERT_EQUAL(freeMem3, freeMem, freeMem3);
+
+ LOS_TaskDelay(10); // 10, task delay times.
+
+ freeMem4 = GetfreeMemSize(m_aucSysMem0);
+ ICUNIT_ASSERT_EQUAL(freeMem4, freeMem, freeMem4);
+ return LOS_OK;
+}
+
+VOID ItLosTask124(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask124", TestCase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/sample/kernel/task/It_los_task_125.c b/testsuites/sample/kernel/task/It_los_task_125.c
new file mode 100644
index 00000000..73bb4efb
--- /dev/null
+++ b/testsuites/sample/kernel/task/It_los_task_125.c
@@ -0,0 +1,92 @@
+/*
+ * 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 "osTest.h"
+#include "It_los_task.h"
+
+static UINT32 GetfreeMemSize(void *pool)
+{
+ return LOS_MemPoolSizeGet(pool) - LOS_MemTotalUsedGet(pool);
+}
+
+static VOID TaskF01(UINT32 arg)
+{
+ g_testCount++;
+ return;
+}
+
+static UINT32 TestCase(VOID)
+{
+ UINT32 freeMem;
+ UINT32 freeMem1;
+ UINT32 freeMem2;
+ UINT32 freeMem3;
+ UINT32 freeMem4;
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk125A";
+ task1.usTaskPrio = 8; // 8, set task priortiy value.
+ g_testCount = 0;
+
+ freeMem = GetfreeMemSize(m_aucSysMem0);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ freeMem1 = GetfreeMemSize(m_aucSysMem0);
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ freeMem2 = GetfreeMemSize(m_aucSysMem0);
+ ICUNIT_ASSERT_EQUAL(freeMem2, freeMem1, freeMem2);
+
+ LOS_TaskDelay(10); // 10, task delay times.
+
+ freeMem3 = GetfreeMemSize(m_aucSysMem0);
+ ICUNIT_ASSERT_EQUAL(freeMem3, freeMem, freeMem3);
+
+ LOS_TaskResRecycle();
+ freeMem4 = GetfreeMemSize(m_aucSysMem0);
+ ICUNIT_ASSERT_EQUAL(freeMem4, freeMem, freeMem4);
+
+ return LOS_OK;
+}
+
+VOID ItLosTask125(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask125", TestCase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
diff --git a/testsuites/sample/kernel/task/It_los_task_126.c b/testsuites/sample/kernel/task/It_los_task_126.c
new file mode 100644
index 00000000..15629214
--- /dev/null
+++ b/testsuites/sample/kernel/task/It_los_task_126.c
@@ -0,0 +1,87 @@
+/*
+ * 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 "osTest.h"
+#include "It_los_task.h"
+
+static UINT32 GetfreeMemSize(void *pool)
+{
+ return LOS_MemPoolSizeGet(pool) - LOS_MemTotalUsedGet(pool);
+}
+
+static VOID TaskF01(UINT32 arg)
+{
+ g_testCount++;
+ return;
+}
+
+static UINT32 TestCase(VOID)
+{
+ UINT32 freeMem;
+ UINT32 freeMem1;
+ UINT32 freeMem2;
+ UINT32 freeMem3;
+ UINT32 freeMem4;
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk016A";
+ task1.usTaskPrio = 8; // 8, set task priortiy value.
+ g_testCount = 0;
+
+ freeMem = GetfreeMemSize(m_aucSysMem0);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ freeMem1 = GetfreeMemSize(m_aucSysMem0);
+
+ LOS_TaskDelay(10); // 10, task delay times.
+
+ freeMem2 = GetfreeMemSize(m_aucSysMem0);
+ ICUNIT_ASSERT_EQUAL(freeMem2, freeMem, freeMem2);
+
+ LOS_TaskResRecycle();
+ freeMem3 = GetfreeMemSize(m_aucSysMem0);
+ ICUNIT_ASSERT_EQUAL(freeMem3, freeMem, freeMem3);
+
+ return LOS_OK;
+}
+
+VOID ItLosTask126(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask126", TestCase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
diff --git a/testsuites/sample/kernel/task/It_los_task_127.c b/testsuites/sample/kernel/task/It_los_task_127.c
new file mode 100644
index 00000000..9409104e
--- /dev/null
+++ b/testsuites/sample/kernel/task/It_los_task_127.c
@@ -0,0 +1,94 @@
+/*
+ * 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 "osTest.h"
+#include "It_los_task.h"
+
+static UINT32 GetfreeMemSize(void *pool)
+{
+ return LOS_MemPoolSizeGet(pool) - LOS_MemTotalUsedGet(pool);
+}
+
+static VOID TaskF01(UINT32 arg)
+{
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 TestCase(VOID)
+{
+ UINT32 freeMem;
+ UINT32 freeMem1;
+ UINT32 freeMem2;
+ UINT32 freeMem3;
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk127A";
+ task1.usTaskPrio = 8; // 8, set task priortiy value.
+ task1.uwResved = LOS_TASK_ATTR_JOINABLE;
+ g_testCount = 0;
+
+ freeMem = GetfreeMemSize(m_aucSysMem0);
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ freeMem1 = GetfreeMemSize(m_aucSysMem0);
+
+ LOS_TaskResRecycle();
+ freeMem2 = GetfreeMemSize(m_aucSysMem0);
+ ICUNIT_ASSERT_EQUAL(freeMem2, freeMem1, freeMem2);
+
+ ret = LOS_TaskJoin(g_testTaskID01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ freeMem3 = GetfreeMemSize(m_aucSysMem0);
+ ICUNIT_ASSERT_EQUAL(freeMem3, freeMem, freeMem3);
+
+ return LOS_OK;
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosTask127(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask127", TestCase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
diff --git a/testsuites/sample/kernel/task/It_los_task_128.c b/testsuites/sample/kernel/task/It_los_task_128.c
new file mode 100644
index 00000000..60396640
--- /dev/null
+++ b/testsuites/sample/kernel/task/It_los_task_128.c
@@ -0,0 +1,103 @@
+/*
+ * 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 "osTest.h"
+#include "It_los_task.h"
+
+static UINT32 g_freeMem1 = 0;
+static UINT32 g_freeMem2 = 0;
+
+static UINT32 GetfreeMemSize(void *pool)
+{
+ return LOS_MemPoolSizeGet(pool) - LOS_MemTotalUsedGet(pool);
+}
+
+static VOID TaskF02(VOID)
+{
+ g_testCount++;
+ return;
+}
+
+static VOID TaskF01(VOID)
+{
+ g_testCount++;
+ return;
+}
+
+static UINT32 TestCase(VOID)
+{
+ UINT32 freeMem;
+ UINT32 freeMem1;
+ UINT32 freeMem2;
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk128A";
+ task1.usTaskPrio = TASK_PRIO_TEST - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+
+ freeMem = GetfreeMemSize(m_aucSysMem0);
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "Tsk128B";
+ task1.usTaskPrio = TASK_PRIO_TEST - 3; // TASK_PRIO_TEST - 3, Set task prio.
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, Here, assert that g_testCount is equal to 2.
+
+ LOS_TaskResRecycle();
+
+ freeMem2 = GetfreeMemSize(m_aucSysMem0);
+ ICUNIT_ASSERT_EQUAL(freeMem2, freeMem, freeMem2);
+
+ return LOS_OK;
+}
+
+VOID ItLosTask128(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask128", TestCase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
diff --git a/utils/los_compiler.h b/utils/los_compiler.h
index 14538a65..450d7aa9 100644
--- a/utils/los_compiler.h
+++ b/utils/los_compiler.h
@@ -351,7 +351,7 @@ typedef volatile INT64 Atomic64;
#endif
#ifndef LOS_NOK
-#define LOS_NOK 1U
+#define LOS_NOK (UINT32)(-1)
#endif
#define OS_FAIL 1